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;
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
typedef long long ll;
#define fi first
#define se second
#define pll pair<ll,ll>
#define pb push_back
#define debug(x) cerr<<#x<<"="<<x<<endl;
#define MP make_pair
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define SZ(x) (ll)x.size()
#define ALL(x) x.begin(),x.end()
#define endl "\n"
const ll inf=1e18;
ll lowbit(ll x){return x&(-x);}
const ll maxn=1111;
ll a[maxn];
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
ll n;cin>>n;
rep(i,1,n+1)cin>>a[i];
ll q;cin>>q;
while(q--){
ll l,r;cin>>l>>r;
ll mx=0;
rep(i,l,r+1){
rep(j,i+1,r+1){
rep(k,j+1,r+1){
if(k-j<j-i)continue;
mx=max(mx,a[i]+a[j]+a[k]);
}
}
}
cout<<mx<<endl;
}
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... |