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;
#define int long long
int n, q;
int arr[500005];
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cin >> n;
for(int i = 0; i < n; i++) cin >> arr[i];
cin >> q;
for(int i = 0; i < q; i++){
int maxm = 0;
int l, r;
cin >> l >> r;
for(int x = l-1; x < (r-2); x++){
for(int j = x+1; j < ((l+r)/2); j++){
for(int y = (j-x)+j; y < r; y++){
//cout << arr[x]+arr[j]+arr[y] << "\n";
maxm = max(maxm, arr[x]+arr[j]+arr[y]);
}
}
}
cout << maxm << "\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... |