Wrong Answer
Code
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int T; cin >> T;
while (T--) {
int N; cin >> N;
vector<long long> A(N);
for (int i = 0; i < N; i++) cin >> A[i];
sort(A.rbegin(), A.rend()); // Sort descending
long long result = 0;
for (int i = 0; i < N; i++) {
if (i % 2 == 0)
result += A[i]; // Roy's turn (0-based even)
else
result -= A[i]; // Hridoy's turn (0-based odd)
}
cout << result << "\n";
}
return 0;
}
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:18:58
- Judged At
- 2025-07-14 16:18:58
- Judged By
- Score
- 5
- Total Time
- 35ms
- Peak Memory
- 580.0 KiB