#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = array<int, 2>;
#define all(x) begin(x), end(x)
#define sz(x) (int) (x).size()
int main() {
cin.tie(0) -> sync_with_stdio(0);
int n, q;
cin >> n >> q;
vector<int> w(n);
for (int &i : w) { cin >> i; }
while (q--) {
int l, r, k;
cin >> l >> r >> k;
--l, --r;
set<int> seen;
int worst = -1;
for (int i = r; i >= l; i--) {
auto it = seen.lower_bound(w[i]);
if (it != begin(seen)) {
it = prev(it);
worst = max(worst, *it + w[i]);
}
seen.insert(w[i]);
}
cout << (worst <= k) << "\n";
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
456 KB |
Output is correct |
6 |
Correct |
8 ms |
348 KB |
Output is correct |
7 |
Correct |
8 ms |
492 KB |
Output is correct |
8 |
Correct |
10 ms |
348 KB |
Output is correct |
9 |
Correct |
4 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
456 KB |
Output is correct |
6 |
Correct |
8 ms |
348 KB |
Output is correct |
7 |
Correct |
8 ms |
492 KB |
Output is correct |
8 |
Correct |
10 ms |
348 KB |
Output is correct |
9 |
Correct |
4 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
11 |
Correct |
149 ms |
576 KB |
Output is correct |
12 |
Correct |
550 ms |
772 KB |
Output is correct |
13 |
Correct |
597 ms |
604 KB |
Output is correct |
14 |
Correct |
1041 ms |
840 KB |
Output is correct |
15 |
Correct |
1078 ms |
604 KB |
Output is correct |
16 |
Correct |
1592 ms |
788 KB |
Output is correct |
17 |
Correct |
1136 ms |
740 KB |
Output is correct |
18 |
Correct |
63 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
3007 ms |
43600 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
3008 ms |
1504 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
456 KB |
Output is correct |
6 |
Correct |
8 ms |
348 KB |
Output is correct |
7 |
Correct |
8 ms |
492 KB |
Output is correct |
8 |
Correct |
10 ms |
348 KB |
Output is correct |
9 |
Correct |
4 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
11 |
Correct |
149 ms |
576 KB |
Output is correct |
12 |
Correct |
550 ms |
772 KB |
Output is correct |
13 |
Correct |
597 ms |
604 KB |
Output is correct |
14 |
Correct |
1041 ms |
840 KB |
Output is correct |
15 |
Correct |
1078 ms |
604 KB |
Output is correct |
16 |
Correct |
1592 ms |
788 KB |
Output is correct |
17 |
Correct |
1136 ms |
740 KB |
Output is correct |
18 |
Correct |
63 ms |
344 KB |
Output is correct |
19 |
Execution timed out |
3029 ms |
12112 KB |
Time limit exceeded |
20 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
456 KB |
Output is correct |
6 |
Correct |
8 ms |
348 KB |
Output is correct |
7 |
Correct |
8 ms |
492 KB |
Output is correct |
8 |
Correct |
10 ms |
348 KB |
Output is correct |
9 |
Correct |
4 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
11 |
Correct |
149 ms |
576 KB |
Output is correct |
12 |
Correct |
550 ms |
772 KB |
Output is correct |
13 |
Correct |
597 ms |
604 KB |
Output is correct |
14 |
Correct |
1041 ms |
840 KB |
Output is correct |
15 |
Correct |
1078 ms |
604 KB |
Output is correct |
16 |
Correct |
1592 ms |
788 KB |
Output is correct |
17 |
Correct |
1136 ms |
740 KB |
Output is correct |
18 |
Correct |
63 ms |
344 KB |
Output is correct |
19 |
Execution timed out |
3007 ms |
43600 KB |
Time limit exceeded |
20 |
Halted |
0 ms |
0 KB |
- |