#include <bits/stdc++.h>
using namespace std;
#define work_with_io ios::sync_with_stdio(0);cin.tie(0);
//#define int long long
signed main() {
std::work_with_io;
int q = 1;
//cin >> q;
while (q--) {
int n, m;
cin >> n >> m;
int a[n];
for (int i = 0; i < n; i++) {
cin >> a[i];
}
int mna = *min_element(a, a + n);
int dp[n];
dp[0] = 1;
for (int i = 1; i < n; i++) {
if (a[i] >= a[i - 1])
dp[i] = dp[i - 1] + 1;
else
dp[i] = 1;
}
for (int tmp = m; tmp--;) {
int l, r, k;
cin >> l >> r >> k;
l--;r--;
if (k < mna) {
if (r-l+1 <= dp[r])
cout << "1\n";
else
cout << "0\n";
} else {
int ans = 1;
int Bg = a[l];
for (int left = l+1; left <= r; left++) {
//int Bg = a[left], Lt = k-a[left];
// Lt = k-Bg
if (a[left] < Bg && a[left] > k - Bg)
ans = 0;
Bg = max(Bg, a[left]);
}
cout << ans << '\n';
}
}
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
0 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
0 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
3 ms |
364 KB |
Output is correct |
12 |
Correct |
6 ms |
364 KB |
Output is correct |
13 |
Correct |
7 ms |
364 KB |
Output is correct |
14 |
Correct |
11 ms |
364 KB |
Output is correct |
15 |
Correct |
12 ms |
364 KB |
Output is correct |
16 |
Correct |
16 ms |
364 KB |
Output is correct |
17 |
Correct |
10 ms |
364 KB |
Output is correct |
18 |
Correct |
15 ms |
364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
518 ms |
10168 KB |
Output is correct |
2 |
Correct |
532 ms |
10140 KB |
Output is correct |
3 |
Correct |
517 ms |
10164 KB |
Output is correct |
4 |
Correct |
519 ms |
10220 KB |
Output is correct |
5 |
Correct |
523 ms |
10380 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2399 ms |
1464 KB |
Output is correct |
2 |
Execution timed out |
3066 ms |
1428 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
0 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
3 ms |
364 KB |
Output is correct |
12 |
Correct |
6 ms |
364 KB |
Output is correct |
13 |
Correct |
7 ms |
364 KB |
Output is correct |
14 |
Correct |
11 ms |
364 KB |
Output is correct |
15 |
Correct |
12 ms |
364 KB |
Output is correct |
16 |
Correct |
16 ms |
364 KB |
Output is correct |
17 |
Correct |
10 ms |
364 KB |
Output is correct |
18 |
Correct |
15 ms |
364 KB |
Output is correct |
19 |
Execution timed out |
3087 ms |
2028 KB |
Time limit exceeded |
20 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
0 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
3 ms |
364 KB |
Output is correct |
12 |
Correct |
6 ms |
364 KB |
Output is correct |
13 |
Correct |
7 ms |
364 KB |
Output is correct |
14 |
Correct |
11 ms |
364 KB |
Output is correct |
15 |
Correct |
12 ms |
364 KB |
Output is correct |
16 |
Correct |
16 ms |
364 KB |
Output is correct |
17 |
Correct |
10 ms |
364 KB |
Output is correct |
18 |
Correct |
15 ms |
364 KB |
Output is correct |
19 |
Correct |
518 ms |
10168 KB |
Output is correct |
20 |
Correct |
532 ms |
10140 KB |
Output is correct |
21 |
Correct |
517 ms |
10164 KB |
Output is correct |
22 |
Correct |
519 ms |
10220 KB |
Output is correct |
23 |
Correct |
523 ms |
10380 KB |
Output is correct |
24 |
Correct |
2399 ms |
1464 KB |
Output is correct |
25 |
Execution timed out |
3066 ms |
1428 KB |
Time limit exceeded |
26 |
Halted |
0 ms |
0 KB |
- |