#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
int a[N], p[N], cep[N];
int main () {
// freopen ("input.txt", "r", stdin);
int n, m;
cin >> n >> m;
for (int i = 1; i <= n; ++i) {
cin >> a[i];
}
for (int i = 1; i <= n - 1; ++i) {
if (a[i] > a[i + 1]) {
p[i] = 1;
}
}
for (int i = 1; i <= n; ++i) p[i] += p[i - 1];
stack <int> s;
for (int i = 1; i <= n; ++i) {
cep[i] = -1;
while (!s.empty() and a[s.top()] <= a[i]) s.pop();
if (!s.empty()) {
cep[i] = s.top();
}
s.push(i);
}
for (int i = 1; i <= m; ++i) {
int l, r, k;
cin >> l >> r >> k;
if (p[r - 1] - p[l - 1] == 0) {
cout << "1\n";
continue;
}
bool tr = 0;
for (int j = l; j <= r; ++j) {
if (cep[j] != -1) {
if (cep[j] >= l and cep[j] <= r and a[cep[j]] + a[j] > k) {
tr = 1;
break;
}
}
}
if (tr) cout << "0\n";
else cout << "1\n";
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4440 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4444 KB |
Output is correct |
5 |
Correct |
1 ms |
4444 KB |
Output is correct |
6 |
Correct |
2 ms |
4440 KB |
Output is correct |
7 |
Correct |
2 ms |
4548 KB |
Output is correct |
8 |
Correct |
2 ms |
4444 KB |
Output is correct |
9 |
Correct |
2 ms |
4444 KB |
Output is correct |
10 |
Correct |
3 ms |
4452 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4440 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4444 KB |
Output is correct |
5 |
Correct |
1 ms |
4444 KB |
Output is correct |
6 |
Correct |
2 ms |
4440 KB |
Output is correct |
7 |
Correct |
2 ms |
4548 KB |
Output is correct |
8 |
Correct |
2 ms |
4444 KB |
Output is correct |
9 |
Correct |
2 ms |
4444 KB |
Output is correct |
10 |
Correct |
3 ms |
4452 KB |
Output is correct |
11 |
Correct |
6 ms |
4444 KB |
Output is correct |
12 |
Correct |
7 ms |
4444 KB |
Output is correct |
13 |
Correct |
10 ms |
4696 KB |
Output is correct |
14 |
Correct |
11 ms |
4700 KB |
Output is correct |
15 |
Correct |
11 ms |
4700 KB |
Output is correct |
16 |
Correct |
19 ms |
4680 KB |
Output is correct |
17 |
Correct |
19 ms |
4552 KB |
Output is correct |
18 |
Correct |
18 ms |
4656 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2243 ms |
14456 KB |
Output is correct |
2 |
Correct |
2243 ms |
14020 KB |
Output is correct |
3 |
Correct |
2232 ms |
14208 KB |
Output is correct |
4 |
Correct |
2162 ms |
14228 KB |
Output is correct |
5 |
Correct |
2148 ms |
14068 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
872 ms |
9396 KB |
Output is correct |
2 |
Correct |
2334 ms |
11100 KB |
Output is correct |
3 |
Correct |
195 ms |
9080 KB |
Output is correct |
4 |
Correct |
183 ms |
9300 KB |
Output is correct |
5 |
Correct |
187 ms |
9296 KB |
Output is correct |
6 |
Execution timed out |
3028 ms |
10416 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4440 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4444 KB |
Output is correct |
5 |
Correct |
1 ms |
4444 KB |
Output is correct |
6 |
Correct |
2 ms |
4440 KB |
Output is correct |
7 |
Correct |
2 ms |
4548 KB |
Output is correct |
8 |
Correct |
2 ms |
4444 KB |
Output is correct |
9 |
Correct |
2 ms |
4444 KB |
Output is correct |
10 |
Correct |
3 ms |
4452 KB |
Output is correct |
11 |
Correct |
6 ms |
4444 KB |
Output is correct |
12 |
Correct |
7 ms |
4444 KB |
Output is correct |
13 |
Correct |
10 ms |
4696 KB |
Output is correct |
14 |
Correct |
11 ms |
4700 KB |
Output is correct |
15 |
Correct |
11 ms |
4700 KB |
Output is correct |
16 |
Correct |
19 ms |
4680 KB |
Output is correct |
17 |
Correct |
19 ms |
4552 KB |
Output is correct |
18 |
Correct |
18 ms |
4656 KB |
Output is correct |
19 |
Correct |
2964 ms |
18008 KB |
Output is correct |
20 |
Correct |
2952 ms |
18216 KB |
Output is correct |
21 |
Execution timed out |
3003 ms |
14424 KB |
Time limit exceeded |
22 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4440 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4444 KB |
Output is correct |
5 |
Correct |
1 ms |
4444 KB |
Output is correct |
6 |
Correct |
2 ms |
4440 KB |
Output is correct |
7 |
Correct |
2 ms |
4548 KB |
Output is correct |
8 |
Correct |
2 ms |
4444 KB |
Output is correct |
9 |
Correct |
2 ms |
4444 KB |
Output is correct |
10 |
Correct |
3 ms |
4452 KB |
Output is correct |
11 |
Correct |
6 ms |
4444 KB |
Output is correct |
12 |
Correct |
7 ms |
4444 KB |
Output is correct |
13 |
Correct |
10 ms |
4696 KB |
Output is correct |
14 |
Correct |
11 ms |
4700 KB |
Output is correct |
15 |
Correct |
11 ms |
4700 KB |
Output is correct |
16 |
Correct |
19 ms |
4680 KB |
Output is correct |
17 |
Correct |
19 ms |
4552 KB |
Output is correct |
18 |
Correct |
18 ms |
4656 KB |
Output is correct |
19 |
Correct |
2243 ms |
14456 KB |
Output is correct |
20 |
Correct |
2243 ms |
14020 KB |
Output is correct |
21 |
Correct |
2232 ms |
14208 KB |
Output is correct |
22 |
Correct |
2162 ms |
14228 KB |
Output is correct |
23 |
Correct |
2148 ms |
14068 KB |
Output is correct |
24 |
Correct |
872 ms |
9396 KB |
Output is correct |
25 |
Correct |
2334 ms |
11100 KB |
Output is correct |
26 |
Correct |
195 ms |
9080 KB |
Output is correct |
27 |
Correct |
183 ms |
9300 KB |
Output is correct |
28 |
Correct |
187 ms |
9296 KB |
Output is correct |
29 |
Execution timed out |
3028 ms |
10416 KB |
Time limit exceeded |
30 |
Halted |
0 ms |
0 KB |
- |