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;
int main(){
cin.tie(0); ios_base::sync_with_stdio(0);
int N;
cin >> N;
vector<int> A(N);
for(int i=0; i<N; i++){
cin >> A[i];
}
int Q;
cin >> Q;
while(Q--){
int L, R;
cin >> L >> R;
L--; R--;
int ans=0;
for(int a=L; a<R-1; a++){
for(int c=a+2; c<=R; c++){
for(int b=a+1; b<=a+(c-a)/2; b++){
ans = max(ans, A[a]+A[b]+A[c]);
}
}
}
cout << ans << '\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... |