#include <bits/stdc++.h>
using namespace std;
#define int long long
int n;int Q;
int ar[200005];
int rmq[22][200005];
int chmx(int l,int r){
int lg=__lg(r-l+1);
return max(rmq[lg][l],rmq[lg][r-(1<<lg)+1]);
}
signed main()
{
cin>>n>>Q;
for(int i=1;i<=n;i++){
cin>>ar[i];
rmq[0][i]=ar[i];
}
for(int i=1;i<=21;i++){
for(int j=1;j+(1<<i)-1<=n;j++){
rmq[i][j]=max(rmq[i-1][j],rmq[i-1][j+(1<<(i-1))]);
}
}
while(Q--){
int t;int l;int r;
cin>>t>>l>>r;
l=max(1ll,r-t);
cout<<chmx(l,r)<<endl;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
495 ms |
35012 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
521 ms |
34860 KB |
Output is correct |
3 |
Correct |
529 ms |
34044 KB |
Output is correct |
4 |
Correct |
575 ms |
35536 KB |
Output is correct |
5 |
Correct |
486 ms |
34492 KB |
Output is correct |
6 |
Correct |
527 ms |
34824 KB |
Output is correct |
7 |
Correct |
560 ms |
34996 KB |
Output is correct |
8 |
Correct |
523 ms |
34560 KB |
Output is correct |
9 |
Correct |
513 ms |
34420 KB |
Output is correct |
10 |
Correct |
500 ms |
33976 KB |
Output is correct |
11 |
Correct |
523 ms |
35460 KB |
Output is correct |
12 |
Correct |
492 ms |
35148 KB |
Output is correct |
13 |
Correct |
548 ms |
35152 KB |
Output is correct |
14 |
Correct |
531 ms |
34368 KB |
Output is correct |
15 |
Correct |
519 ms |
35476 KB |
Output is correct |
16 |
Correct |
512 ms |
35108 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
455 ms |
31468 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |