/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Accepted 1ms 764.0 KiB
#3 Accepted 1ms 532.0 KiB
#4 Accepted 1ms 532.0 KiB
#5 Wrong Answer 18ms 532.0 KiB
#6 Wrong Answer 13ms 532.0 KiB

Code

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

signed main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int tc; cin >> tc;

    test:
    while (tc--) {
        ll n; cin >> n;
        
        ll arr[n];
        for (auto &u : arr) cin >> u;
        sort(arr, arr+n);
        reverse(arr, arr+n);

        if (n == 2) {
            cout << arr[0] - arr[1] << "\n";
            goto test;
        }
        
        ll roy = -1e18, hridoy = 1e18, temp = 0;
        for (ll i = 0; i < 4; i++) {
            if (i & 1) temp -= arr[i];
            else temp += arr[i];

            if (i == 0) continue;
            if (i & 1) hridoy = min(hridoy, temp);
            else roy = max(roy, temp);
        }

        cout << max(roy, hridoy) << "\n";
        
    }
}

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 16:39:27
Judged At
2025-07-14 16:39:27
Judged By
Score
5
Total Time
18ms
Peak Memory
764.0 KiB