#include <bits/stdc++.h>
#define F first
#define S second
#define ll long long
using namespace std;
typedef pair<long long,long long> ii;
typedef pair<int,ii> i3;
const int N = 2e5+5;
i3 x[N];
ll n,q;
ll a[N],b[N];
ll st[4*N];
void ini(int no,int u,int v)
{
if (u==v) {
st[no] = a[u];
return;
}
int mid = (u+v)/2;
ini(no*2+1,u,mid);
ini(no*2+2,mid+1,v);
st[no] = max(st[no*2+1],st[no*2+2]);
return;
}
ll r;
void get(int no,int in,int fin,int u,int v)
{
if (fin < u || in > v) return;
if (u<=in && fin <= v) {
r = max(r,st[no]);
return;
}
int mid= (in+fin)/2;
get(no*2+1,in,mid,u,v);
get(no*2+2,mid+1,fin,u,v);
return;
}
int main()
{
cin.tie(0); ios_base::sync_with_stdio(0);
cin >> n >> q;
for (int i=1;i<=n;i++)
cin >> a[i];
for (int i=0;i<q;i++) cin >> x[i].F >> x[i].S.F >> x[i].S.S;
ini(0,1,n);
for (int i=0;i<q;i++) {
r = 0;
get(0,1,n,max(1ll,x[i].S.F-x[i].F),x[i].S.F);
cout << r << "\n";
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Incorrect |
170 ms |
16308 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
174 ms |
16448 KB |
Output is correct |
3 |
Correct |
177 ms |
17908 KB |
Output is correct |
4 |
Correct |
170 ms |
18260 KB |
Output is correct |
5 |
Correct |
167 ms |
17748 KB |
Output is correct |
6 |
Correct |
172 ms |
17952 KB |
Output is correct |
7 |
Correct |
166 ms |
17988 KB |
Output is correct |
8 |
Correct |
173 ms |
18244 KB |
Output is correct |
9 |
Correct |
168 ms |
18000 KB |
Output is correct |
10 |
Correct |
166 ms |
17736 KB |
Output is correct |
11 |
Correct |
171 ms |
18236 KB |
Output is correct |
12 |
Correct |
173 ms |
17896 KB |
Output is correct |
13 |
Correct |
172 ms |
18248 KB |
Output is correct |
14 |
Correct |
176 ms |
18008 KB |
Output is correct |
15 |
Correct |
171 ms |
18020 KB |
Output is correct |
16 |
Correct |
166 ms |
17824 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
159 ms |
14476 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |