This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |