-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathA.cpp
More file actions
30 lines (23 loc) · 724 Bytes
/
A.cpp
File metadata and controls
30 lines (23 loc) · 724 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
int t; // Number of test cases
cin >> t;
while (t--) {
int n;
cin >> n; // Length of the array
vector<int> a(n);
for (int i = 0; i < n; ++i) {
cin >> a[i]; // Input array elements
}
// Find the maximum element
int maxElement = *max_element(a.begin(), a.end());
// The number of red elements we can choose = (n + 1) / 2
int redCount = (n + 1) / 2;
// The score is the maxElement + redCount
cout << maxElement + redCount << endl;
}
return 0;
}