#include <bits/stdc++.h>
using namespace std;
const int maxn=1e6+5;
int n,m;
int w[maxn], pref[maxn];
bool check(int l, int r, int k)
{
int mx=0;
int res=0;
for(int i=l; i<=r; i++)
{
if(mx>w[i])
res=max(res ,mx+w[i]);
mx=max(mx,w[i]);
}
return k>=res;
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n >> m;
int mn=1e9;
for(int i=1; i<=n; i++)
{
cin >> w[i];
mn=min(mn, w[i]);
}
for(int i=2; i<=n; i++)
{
pref[i]=pref[i-1];
if(w[i-1]<=w[i])
pref[i]++;
}
int l, r, k;
for(int i=1; i<=m; i++)
{
cin >> l >> r >> k;
if(mn>k)
{
if(pref[r]-pref[l]==r-l)
cout << 1 << "\n";
else
cout << 0 << "\n";
}
else
{
if(check(l, r, k))
cout << 1 << "\n";
else
cout << 0 << "\n";
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
352 KB |
Output is correct |
7 |
Correct |
0 ms |
352 KB |
Output is correct |
8 |
Correct |
0 ms |
352 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
352 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
352 KB |
Output is correct |
7 |
Correct |
0 ms |
352 KB |
Output is correct |
8 |
Correct |
0 ms |
352 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
352 KB |
Output is correct |
11 |
Correct |
2 ms |
352 KB |
Output is correct |
12 |
Correct |
4 ms |
596 KB |
Output is correct |
13 |
Correct |
4 ms |
608 KB |
Output is correct |
14 |
Correct |
6 ms |
604 KB |
Output is correct |
15 |
Correct |
6 ms |
604 KB |
Output is correct |
16 |
Correct |
13 ms |
636 KB |
Output is correct |
17 |
Correct |
8 ms |
616 KB |
Output is correct |
18 |
Correct |
10 ms |
600 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
264 ms |
42032 KB |
Output is correct |
2 |
Correct |
248 ms |
43104 KB |
Output is correct |
3 |
Correct |
246 ms |
42956 KB |
Output is correct |
4 |
Correct |
267 ms |
43092 KB |
Output is correct |
5 |
Correct |
253 ms |
43104 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1442 ms |
3420 KB |
Output is correct |
2 |
Execution timed out |
3034 ms |
2768 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
352 KB |
Output is correct |
7 |
Correct |
0 ms |
352 KB |
Output is correct |
8 |
Correct |
0 ms |
352 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
352 KB |
Output is correct |
11 |
Correct |
2 ms |
352 KB |
Output is correct |
12 |
Correct |
4 ms |
596 KB |
Output is correct |
13 |
Correct |
4 ms |
608 KB |
Output is correct |
14 |
Correct |
6 ms |
604 KB |
Output is correct |
15 |
Correct |
6 ms |
604 KB |
Output is correct |
16 |
Correct |
13 ms |
636 KB |
Output is correct |
17 |
Correct |
8 ms |
616 KB |
Output is correct |
18 |
Correct |
10 ms |
600 KB |
Output is correct |
19 |
Execution timed out |
3040 ms |
6740 KB |
Time limit exceeded |
20 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
352 KB |
Output is correct |
7 |
Correct |
0 ms |
352 KB |
Output is correct |
8 |
Correct |
0 ms |
352 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
352 KB |
Output is correct |
11 |
Correct |
2 ms |
352 KB |
Output is correct |
12 |
Correct |
4 ms |
596 KB |
Output is correct |
13 |
Correct |
4 ms |
608 KB |
Output is correct |
14 |
Correct |
6 ms |
604 KB |
Output is correct |
15 |
Correct |
6 ms |
604 KB |
Output is correct |
16 |
Correct |
13 ms |
636 KB |
Output is correct |
17 |
Correct |
8 ms |
616 KB |
Output is correct |
18 |
Correct |
10 ms |
600 KB |
Output is correct |
19 |
Correct |
264 ms |
42032 KB |
Output is correct |
20 |
Correct |
248 ms |
43104 KB |
Output is correct |
21 |
Correct |
246 ms |
42956 KB |
Output is correct |
22 |
Correct |
267 ms |
43092 KB |
Output is correct |
23 |
Correct |
253 ms |
43104 KB |
Output is correct |
24 |
Correct |
1442 ms |
3420 KB |
Output is correct |
25 |
Execution timed out |
3034 ms |
2768 KB |
Time limit exceeded |
26 |
Halted |
0 ms |
0 KB |
- |