QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#670838 | #7941. Jackpot | maelys | Compile Error | / | / | C++17 | 549b | 2024-10-24 04:25:15 | 2024-10-24 04:25:15 |
Judging History
answer
#include <iostream>
#include <vector>
using namespace std;
void solve(){
int n;
cin >> n;
int n2 = 2*n;
vector<int> v(n2);
for(int i = 0; i < n2; i++) {
cin >> v[i];
}
nth_element(v.begin(), v.begin() + n, v.end());
long long sum = 0;
for(int i = 0; i < n; i++)
sum -= v[i];
for(int i = n; i < n2; i++)
sum += v[i];
cout<<sum<<'\n';
}
int main() {
int t;
cin >> t;
vector<long long> ans;
while(t--){
solve();
}
return 0;
}
Details
answer.code: In function ‘void solve()’: answer.code:16:3: error: ‘nth_element’ was not declared in this scope 16 | nth_element(v.begin(), v.begin() + n, v.end()); | ^~~~~~~~~~~