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;
int32_t main(){
ios::sync_with_stdio(0);cin.tie(0);
int n;
cin >> n;
long long arr[n];
for(int i=0; i<n; i++) cin >> arr[i];
int q;
cin >> q;
while(q--){
int l,r;
cin >> l >> r;
l--; r--;
long long ans=0;
for(int a=l; a<=r; a++){
for(int b=a+1; b<=r; b++){
for(int c=b*2-a; c<=r; c++) ans=max(ans,arr[a]+arr[b]+arr[c]);
}
}
cout << ans << '\n';
}
}
# | 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... |