이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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());
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... |