QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#670838#7941. JackpotmaelysCompile Error//C++17549b2024-10-24 04:25:152024-10-24 04:25:15

Judging History

你现在查看的是最新测评结果

  • [2024-10-24 04:25:15]
  • 评测
  • [2024-10-24 04:25:15]
  • 提交

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());
      |   ^~~~~~~~~~~