/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Accepted 1ms 532.0 KiB
#3 Accepted 1ms 324.0 KiB
#4 Accepted 1ms 532.0 KiB
#5 Accepted 14ms 568.0 KiB
#6 Accepted 11ms 532.0 KiB
#7 Accepted 30ms 1.27 MiB
#8 Accepted 36ms 1.27 MiB
#9 Accepted 40ms 1.059 MiB
#10 Accepted 34ms 1.273 MiB
#11 Wrong Answer 11ms 580.0 KiB
#12 Wrong Answer 12ms 572.0 KiB

Code

#include <bits/stdc++.h>
using namespace std;

void solve() {
    int n; cin >> n;
    int a[n]; for (auto& x : a) cin >> x;
    sort(a, a+n, greater<>());
    long long S = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] < 0) break;
        S += i & 1 ? -a[i] : a[i];
    }
    cout << S << "\n";
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int t; cin >> t; while (t--)
        solve();
}

Information

Submit By
Type
Submission
Problem
P1208 C. Game on Integer
Contest
Educational Round 1
Language
C++17 (G++ 13.2.0)
Submit At
2025-07-14 17:15:04
Judged At
2025-07-14 17:15:04
Judged By
Score
60
Total Time
40ms
Peak Memory
1.273 MiB