QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#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;
}
详细
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()); | ^~~~~~~~~~~