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
#define ii pair<int,int>
typedef vector<int> vi;
#define iii tuple<int,int,int>
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef map<int,int> mii;
#ifndef debug
#define cerr if (0) cerr
#endif
int N, Q, L, R, ans;
int32_t main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cin>>N; vi A(N+5);
for (int i=1; i<=N; i++) cin>>A[i];
cin>>Q;
while (Q--){
cin>>L>>R;
ans = 0;
for (int i=L; i<=R; i++){
for (int j=i+1; j<=R; j++){
for (int k=j+1; k<=R; k++){
if (!(j-i <= k-j)) continue;
ans=max(ans, A[i]+A[j]+A[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... |