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
const int MAX_VAL=500*1000+5;
int nbVal,nbReq,debReq,finReq,rep;
int val[MAX_VAL];
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin>>nbVal;
for (int i=1;i<=nbVal;i++) {
cin>>val[i];
}
cin>>nbReq;
for (int j=1;j<=nbReq;j++) {
cin>>debReq>>finReq;
rep=0;
for (int a=debReq;a<=finReq;a++) {
for (int b=a+1;b<=finReq;b++) {
for (int c=b+1;c<=finReq;c++) {
if(b-a<=c-b) {
rep=max(rep,val[a]+val[b]+val[c]);
}
}
}
}
cout<<rep<<endl;
}
}
# | 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... |