QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#555644#8586. PartyJioruCompile Error//C++20436b2024-09-10 07:22:072024-09-10 07:22:08

Judging History

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

  • [2024-09-10 07:22:08]
  • 评测
  • [2024-09-10 07:22:07]
  • 提交

answer

#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int main() {
    int n;
    cin >> n;
    
    vector<int> arr(n);
    for (int i = 0; i < n; ++i)
        cin >> arr[i];
    
    sort(arr.begin(), arr.end(), [](int a, int b) {
        return a > b;
    });
    
    ll ans = 0;
    for (int i = 0; i < (n + 1) / 2; ++i)
        ans += max(arr[i], 0);
    
    cout << ans << endl;
    return 0;
}

Details

answer.code: In function ‘int main()’:
answer.code:16:5: error: ‘ll’ was not declared in this scope
   16 |     ll ans = 0;
      |     ^~
answer.code:18:9: error: ‘ans’ was not declared in this scope; did you mean ‘abs’?
   18 |         ans += max(arr[i], 0);
      |         ^~~
      |         abs
answer.code:20:13: error: ‘ans’ was not declared in this scope; did you mean ‘abs’?
   20 |     cout << ans << endl;
      |             ^~~
      |             abs