#include <bits/stdc++.h>
using namespace std;
#define intt long long
#define fi first
#define se second
const int N = 5e5+3;
intt a[N],n,m;
pair<intt,intt> b[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>>m;
for(int i=1 ; i<=m;i++){
cin>>b[i].fi>>b[i].se;
}
for(int i=1 ; i<=m;i++){
intt ans=0;
for(intt z=b[i].fi+2 ;z<=b[i].se;z++){
for(intt y=b[i].fi +1; y<z;y++){
for(intt x=b[i].fi; x<y;x++){
if(x+z-2*y >=0){
ans=max(ans , a[x]+a[y]+a[z]);
}
}
}
}
cout<<ans<<"\n";
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
2 ms |
348 KB |
Output is correct |
3 |
Correct |
2 ms |
348 KB |
Output is correct |
4 |
Correct |
2 ms |
460 KB |
Output is correct |
5 |
Correct |
2 ms |
348 KB |
Output is correct |
6 |
Correct |
2 ms |
348 KB |
Output is correct |
7 |
Correct |
2 ms |
348 KB |
Output is correct |
8 |
Correct |
2 ms |
348 KB |
Output is correct |
9 |
Correct |
2 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
2 ms |
348 KB |
Output is correct |
3 |
Correct |
2 ms |
348 KB |
Output is correct |
4 |
Correct |
2 ms |
460 KB |
Output is correct |
5 |
Correct |
2 ms |
348 KB |
Output is correct |
6 |
Correct |
2 ms |
348 KB |
Output is correct |
7 |
Correct |
2 ms |
348 KB |
Output is correct |
8 |
Correct |
2 ms |
348 KB |
Output is correct |
9 |
Correct |
2 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Execution timed out |
4038 ms |
13136 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
4062 ms |
3664 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
2 ms |
348 KB |
Output is correct |
3 |
Correct |
2 ms |
348 KB |
Output is correct |
4 |
Correct |
2 ms |
460 KB |
Output is correct |
5 |
Correct |
2 ms |
348 KB |
Output is correct |
6 |
Correct |
2 ms |
348 KB |
Output is correct |
7 |
Correct |
2 ms |
348 KB |
Output is correct |
8 |
Correct |
2 ms |
348 KB |
Output is correct |
9 |
Correct |
2 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Execution timed out |
4038 ms |
13136 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |