#include <bits/stdc++.h>
using namespace std;
const int N = (int) 5e5 + 7;
const int INF = (int) 1e9 + 7;
int n;
int q;
int a[N];
signed main() {
ios::sync_with_stdio(0); cin.tie(0);
//freopen ("input", "r", stdin);
vector<pair<int, int>> elements;
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
elements.push_back({a[i], i});
}
sort(elements.rbegin(), elements.rend());
int lim = 100;
if ((int) elements.size() >= lim) {
elements.resize(lim);
}
int sol = 0;
for (int i = 0; i < (int) elements.size(); i++) {
for (int j = 0; j < i; j++) {
for (int k = 0; k < j; k++) {
vector<int> all = {elements[i].second, elements[j].second, elements[k].second};
sort(all.begin(), all.end());
assert(all[0] < all[1] && all[1] < all[2]);
if (all[1] * 2 <= all[0] + all[2]) {
sol = max(sol, elements[i].first + elements[j].first + elements[k].first);
}
}
}
}
cout << sol << "\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Incorrect |
6 ms |
204 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Incorrect |
6 ms |
204 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
41 ms |
2980 KB |
Output is correct |
2 |
Correct |
28 ms |
3028 KB |
Output is correct |
3 |
Correct |
29 ms |
3016 KB |
Output is correct |
4 |
Correct |
40 ms |
2928 KB |
Output is correct |
5 |
Correct |
40 ms |
3016 KB |
Output is correct |
6 |
Incorrect |
40 ms |
2964 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Incorrect |
6 ms |
204 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |