This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 5e5 + 3e2;
#define MP make_pair
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
pair<int, int> arr[N];
void solve(){
int n;
cin >> n;
vector<int> perm(n);
for (int i = 1; i <= n; i++){
cin >> arr[i].first;
arr[i].second = i;
}
sort(arr + 1, arr + n + 1);
reverse(arr + 1, arr + n + 1);
int q;
cin >> q >> q >> q;
for (int i = 1; i <= n; i++){
for (int j = i + 1; j <= n; j++){
for (int k = j + 1; k <= n; k++){
int a = arr[i].second, b = arr[j].second, c = arr[k].second;
if (a > c) swap(a, c); /// a < c
if (b > c) swap(b, c); /// b < c
if (a > b) swap(a, b); /// a < b;
if (b - a <= c - b){
cout << arr[i].first + arr[j].first + arr[k].first << endl;
return;
}
}
}
}
}
int main(){
ios_base::sync_with_stdio(false);
//freopen("output.txt", "w", stdout);
int tests = 1;
// cin >> tests;
while (tests--){
solve();
}
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... |