#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 1e6 + 5;
int w[MAX_N];
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
int N, M;
cin >> N >> M;
for(int i = 1; i <= N; i++) {
cin >> w[i];
}
while(M--) {
int l, r, k;
cin >> l >> r >> k;
multiset <int> s;
for(int i = l; i <= r; i++) {
s.insert(w[i]);
}
int ma = 0;
for(int i = l; i < r; i++) {
s.erase(s.lower_bound(w[i]));
auto it = s.lower_bound(w[i]);
if(it != s.begin()) {
ma = max(ma, w[i] + *prev(it));
}
}
cout << (ma <= k) << '\n';
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
3 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
16 ms |
340 KB |
Output is correct |
7 |
Correct |
16 ms |
372 KB |
Output is correct |
8 |
Correct |
23 ms |
340 KB |
Output is correct |
9 |
Correct |
8 ms |
340 KB |
Output is correct |
10 |
Correct |
17 ms |
288 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
3 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
16 ms |
340 KB |
Output is correct |
7 |
Correct |
16 ms |
372 KB |
Output is correct |
8 |
Correct |
23 ms |
340 KB |
Output is correct |
9 |
Correct |
8 ms |
340 KB |
Output is correct |
10 |
Correct |
17 ms |
288 KB |
Output is correct |
11 |
Correct |
291 ms |
464 KB |
Output is correct |
12 |
Correct |
1028 ms |
660 KB |
Output is correct |
13 |
Correct |
1228 ms |
724 KB |
Output is correct |
14 |
Correct |
2011 ms |
840 KB |
Output is correct |
15 |
Correct |
2076 ms |
724 KB |
Output is correct |
16 |
Correct |
2969 ms |
800 KB |
Output is correct |
17 |
Correct |
1677 ms |
628 KB |
Output is correct |
18 |
Correct |
2008 ms |
668 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
3065 ms |
30764 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
3091 ms |
5020 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
3 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
16 ms |
340 KB |
Output is correct |
7 |
Correct |
16 ms |
372 KB |
Output is correct |
8 |
Correct |
23 ms |
340 KB |
Output is correct |
9 |
Correct |
8 ms |
340 KB |
Output is correct |
10 |
Correct |
17 ms |
288 KB |
Output is correct |
11 |
Correct |
291 ms |
464 KB |
Output is correct |
12 |
Correct |
1028 ms |
660 KB |
Output is correct |
13 |
Correct |
1228 ms |
724 KB |
Output is correct |
14 |
Correct |
2011 ms |
840 KB |
Output is correct |
15 |
Correct |
2076 ms |
724 KB |
Output is correct |
16 |
Correct |
2969 ms |
800 KB |
Output is correct |
17 |
Correct |
1677 ms |
628 KB |
Output is correct |
18 |
Correct |
2008 ms |
668 KB |
Output is correct |
19 |
Execution timed out |
3074 ms |
11032 KB |
Time limit exceeded |
20 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
3 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
16 ms |
340 KB |
Output is correct |
7 |
Correct |
16 ms |
372 KB |
Output is correct |
8 |
Correct |
23 ms |
340 KB |
Output is correct |
9 |
Correct |
8 ms |
340 KB |
Output is correct |
10 |
Correct |
17 ms |
288 KB |
Output is correct |
11 |
Correct |
291 ms |
464 KB |
Output is correct |
12 |
Correct |
1028 ms |
660 KB |
Output is correct |
13 |
Correct |
1228 ms |
724 KB |
Output is correct |
14 |
Correct |
2011 ms |
840 KB |
Output is correct |
15 |
Correct |
2076 ms |
724 KB |
Output is correct |
16 |
Correct |
2969 ms |
800 KB |
Output is correct |
17 |
Correct |
1677 ms |
628 KB |
Output is correct |
18 |
Correct |
2008 ms |
668 KB |
Output is correct |
19 |
Execution timed out |
3065 ms |
30764 KB |
Time limit exceeded |
20 |
Halted |
0 ms |
0 KB |
- |