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 fi first
#define se second
#define ll long long
#define li pair<ll,int>
#define i2 pair<int,int>
using namespace std;
int n,q;
ll a[500003],mx[500003];
void sub1(){
for (int i=1;i<=q;i++){
int l,r;
cin>>l>>r;
ll kq=0;
for (int j=l;j<=r;j++){
for (int k=j+1;k<=r;k++){
for (int l=k+1;l<=r;l++){
if (k-j<=l-k) kq=max(kq,a[j]+a[k]+a[l]);
}
}
}
cout<<kq<<"\n";
}
}
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//freopen("CHONQUA.inp","r",stdin);
//freopen("CHONQUA.out","w",stdout);
cin>>n;
for (int i=1;i<=n;i++) cin>>a[i];
cin>>q;
sub1();
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... |