#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
void solve(){
int n, m;
cin >> n >> m;
long long a[n+1], b, mx=0, li, ri, ki;
for(int i=1; i<=n; i++)
cin >> a[i];
for(int i=1; i<=m; i++){
bool y=0;
b = 0;
cin >> li >> ri >> ki;
for(int e=li; e<=ri; e++){
if(b<a[e]){
if(b+mx>ki)
break;
mx = 0;
if(e!=ri && a[e]>a[e+1]){
y=1; b=a[e]; }
}
if(y && a[e]<b)
mx = max(a[e], mx);
}
//cout << b << ' ' << mx << "\n";
if(b+mx>ki)
cout << 0 << "\n";
else
cout << 1 << "\n";
mx = 0;
}
}
int main()
{
IOS;
int t=1;
//cin >> t;
while(t--){
solve();
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
3 ms |
332 KB |
Output is correct |
12 |
Correct |
2 ms |
332 KB |
Output is correct |
13 |
Correct |
2 ms |
332 KB |
Output is correct |
14 |
Correct |
4 ms |
356 KB |
Output is correct |
15 |
Correct |
3 ms |
352 KB |
Output is correct |
16 |
Correct |
21 ms |
352 KB |
Output is correct |
17 |
Correct |
21 ms |
340 KB |
Output is correct |
18 |
Correct |
26 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
622 ms |
10120 KB |
Output is correct |
2 |
Correct |
579 ms |
10036 KB |
Output is correct |
3 |
Correct |
579 ms |
10144 KB |
Output is correct |
4 |
Correct |
550 ms |
10012 KB |
Output is correct |
5 |
Execution timed out |
3073 ms |
8132 KB |
Time limit exceeded |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
680 ms |
1280 KB |
Output is correct |
2 |
Correct |
2052 ms |
1372 KB |
Output is correct |
3 |
Execution timed out |
3058 ms |
1220 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
3 ms |
332 KB |
Output is correct |
12 |
Correct |
2 ms |
332 KB |
Output is correct |
13 |
Correct |
2 ms |
332 KB |
Output is correct |
14 |
Correct |
4 ms |
356 KB |
Output is correct |
15 |
Correct |
3 ms |
352 KB |
Output is correct |
16 |
Correct |
21 ms |
352 KB |
Output is correct |
17 |
Correct |
21 ms |
340 KB |
Output is correct |
18 |
Correct |
26 ms |
348 KB |
Output is correct |
19 |
Correct |
2248 ms |
2356 KB |
Output is correct |
20 |
Correct |
2218 ms |
2320 KB |
Output is correct |
21 |
Execution timed out |
3080 ms |
2216 KB |
Time limit exceeded |
22 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
3 ms |
332 KB |
Output is correct |
12 |
Correct |
2 ms |
332 KB |
Output is correct |
13 |
Correct |
2 ms |
332 KB |
Output is correct |
14 |
Correct |
4 ms |
356 KB |
Output is correct |
15 |
Correct |
3 ms |
352 KB |
Output is correct |
16 |
Correct |
21 ms |
352 KB |
Output is correct |
17 |
Correct |
21 ms |
340 KB |
Output is correct |
18 |
Correct |
26 ms |
348 KB |
Output is correct |
19 |
Correct |
622 ms |
10120 KB |
Output is correct |
20 |
Correct |
579 ms |
10036 KB |
Output is correct |
21 |
Correct |
579 ms |
10144 KB |
Output is correct |
22 |
Correct |
550 ms |
10012 KB |
Output is correct |
23 |
Execution timed out |
3073 ms |
8132 KB |
Time limit exceeded |