1 solutions
-
0
C++ :
#include<bits/stdc++.h> using namespace std; typedef long long ll; int a[200005]; bool cmp(int a, int b) { return a > b; } void cal(int n) { ll b = 0, c = 0; for (int i = 0; i < n; i++) { if (i % 2 == 0 && a[i] % 2 == 0) b += a[i]; else if (i % 2 != 0 && a[i] % 2 != 0) c += a[i]; } if (b > c) cout << "A" << endl; else if (c > b) cout << "B" << endl; else cout << 'C' << endl; } int main() { int n, t; cin >> t; for (int i = 0; i < t; i++) { cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; sort(a, a + n, cmp); cal(n); } }
- 1
Information
- ID
- 226
- Time
- 1000ms
- Memory
- 128MiB
- Difficulty
- 10
- Tags
- # Submissions
- 1
- Accepted
- 1
- Uploaded By