-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2021A.cpp
More file actions
executable file
·48 lines (38 loc) · 930 Bytes
/
Copy path2021A.cpp
File metadata and controls
executable file
·48 lines (38 loc) · 930 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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int maxValue(vector<int> a) {
if (a.size() == 1) {
return a[0];
}
int max_result = 0;
for (int i = 0; i < a.size(); ++i) {
for (int j = i + 1; j < a.size(); ++j) {
int average = (a[i] + a[j]) / 2;
vector<int> new_array;
for (int k = 0; k < a.size(); ++k) {
if (k != i && k != j) {
new_array.push_back(a[k]);
}
}
new_array.push_back(average);
max_result = max(max_result, maxValue(new_array));
}
}
return max_result;
}
int main() {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; ++i) {
cin >> a[i];
}
cout << maxValue(a) << endl;
}
return 0;
}