#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 |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
2 ms |
344 KB |
Output is correct |
12 |
Correct |
4 ms |
348 KB |
Output is correct |
13 |
Correct |
4 ms |
348 KB |
Output is correct |
14 |
Correct |
6 ms |
512 KB |
Output is correct |
15 |
Correct |
7 ms |
348 KB |
Output is correct |
16 |
Correct |
10 ms |
512 KB |
Output is correct |
17 |
Correct |
9 ms |
348 KB |
Output is correct |
18 |
Correct |
10 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
245 ms |
10236 KB |
Output is correct |
2 |
Correct |
243 ms |
10064 KB |
Output is correct |
3 |
Correct |
237 ms |
10124 KB |
Output is correct |
4 |
Correct |
241 ms |
10112 KB |
Output is correct |
5 |
Correct |
238 ms |
10396 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1461 ms |
1344 KB |
Output is correct |
2 |
Execution timed out |
3039 ms |
1360 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 |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
2 ms |
344 KB |
Output is correct |
12 |
Correct |
4 ms |
348 KB |
Output is correct |
13 |
Correct |
4 ms |
348 KB |
Output is correct |
14 |
Correct |
6 ms |
512 KB |
Output is correct |
15 |
Correct |
7 ms |
348 KB |
Output is correct |
16 |
Correct |
10 ms |
512 KB |
Output is correct |
17 |
Correct |
9 ms |
348 KB |
Output is correct |
18 |
Correct |
10 ms |
344 KB |
Output is correct |
19 |
Execution timed out |
3066 ms |
2044 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 |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
2 ms |
344 KB |
Output is correct |
12 |
Correct |
4 ms |
348 KB |
Output is correct |
13 |
Correct |
4 ms |
348 KB |
Output is correct |
14 |
Correct |
6 ms |
512 KB |
Output is correct |
15 |
Correct |
7 ms |
348 KB |
Output is correct |
16 |
Correct |
10 ms |
512 KB |
Output is correct |
17 |
Correct |
9 ms |
348 KB |
Output is correct |
18 |
Correct |
10 ms |
344 KB |
Output is correct |
19 |
Correct |
245 ms |
10236 KB |
Output is correct |
20 |
Correct |
243 ms |
10064 KB |
Output is correct |
21 |
Correct |
237 ms |
10124 KB |
Output is correct |
22 |
Correct |
241 ms |
10112 KB |
Output is correct |
23 |
Correct |
238 ms |
10396 KB |
Output is correct |
24 |
Correct |
1461 ms |
1344 KB |
Output is correct |
25 |
Execution timed out |
3039 ms |
1360 KB |
Time limit exceeded |
26 |
Halted |
0 ms |
0 KB |
- |