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>
#define f0r(i,n) for(int i = 0;i<n;i++)
#define pb push_back
#define vll vector<long long int>
using namespace std;
typedef long long int ll;
int main(){
int n;
cin>>n;
vll v(n);
f0r(i,n){
cin>>v[i];
}
int q;
cin>>q;
while(q--){
int l,r;
cin>>l>>r;
l--;
r--;
ll ans = 0;
for(int i = l;i<r-1;i++){
for(int j = i+1;j<r;j++){
for(int k = i+1;k<=r;k++){
if(k-j >= j-i){
ans = max(ans, v[i] + v[j] + v[k]);
}
}
}
}
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... |