답안 #853868

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
853868 2023-09-25T11:11:33 Z Trisanu_Das Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++17
100 / 100
680 ms 93732 KB
#include<bits/stdc++.h>
using namespace std;

const int maxn = 1 << 20;
int n, m, a[maxn], f[maxn], ans[maxn];
vector<array<int, 3> > q[maxn];

void upd(int i, int x) {
	for(;i; i -= i&-i) f[i] = max(f[i], x); 
}
int get(int i) {
	int r = 0;
	for(;i <= n; i += i&-i) r = max(f[i], r);
	return r; 
}
int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin >> n >> m;
	a[0] = 1<<30;
	for(int i = 1; i <= n; i++) cin >> a[i];
	for(int l, r, k, i = 0; i < m; i++) {
		cin >> l >> r >> k;
		q[r].push_back({l, k, i});
	}
	vector<int> t {0};
	for(int i = 1; i <= n; i++) {
		while(a[t.back()] <= a[i]) t.pop_back();
		if(t.back()) upd(t.back(), a[t.back()] + a[i]);
		t.push_back(i);
		for(auto [l, k, p] : q[i]) ans[p] = get(l) <= k;
	}
	for(int i = 0; i < m; i++) cout << ans[i] << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 27480 KB Output is correct
2 Correct 6 ms 27228 KB Output is correct
3 Correct 6 ms 27228 KB Output is correct
4 Correct 7 ms 27544 KB Output is correct
5 Correct 5 ms 27228 KB Output is correct
6 Correct 6 ms 27228 KB Output is correct
7 Correct 6 ms 27228 KB Output is correct
8 Correct 6 ms 27228 KB Output is correct
9 Correct 6 ms 27228 KB Output is correct
10 Correct 6 ms 27320 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 27480 KB Output is correct
2 Correct 6 ms 27228 KB Output is correct
3 Correct 6 ms 27228 KB Output is correct
4 Correct 7 ms 27544 KB Output is correct
5 Correct 5 ms 27228 KB Output is correct
6 Correct 6 ms 27228 KB Output is correct
7 Correct 6 ms 27228 KB Output is correct
8 Correct 6 ms 27228 KB Output is correct
9 Correct 6 ms 27228 KB Output is correct
10 Correct 6 ms 27320 KB Output is correct
11 Correct 6 ms 27228 KB Output is correct
12 Correct 7 ms 27484 KB Output is correct
13 Correct 7 ms 27320 KB Output is correct
14 Correct 8 ms 27484 KB Output is correct
15 Correct 8 ms 27780 KB Output is correct
16 Correct 8 ms 27484 KB Output is correct
17 Correct 7 ms 27480 KB Output is correct
18 Correct 8 ms 27480 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 643 ms 92396 KB Output is correct
2 Correct 674 ms 93652 KB Output is correct
3 Correct 655 ms 93340 KB Output is correct
4 Correct 643 ms 93464 KB Output is correct
5 Correct 660 ms 91276 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 53 ms 35864 KB Output is correct
2 Correct 42 ms 35828 KB Output is correct
3 Correct 41 ms 35408 KB Output is correct
4 Correct 43 ms 35664 KB Output is correct
5 Correct 42 ms 35664 KB Output is correct
6 Correct 36 ms 35412 KB Output is correct
7 Correct 35 ms 35152 KB Output is correct
8 Correct 41 ms 35092 KB Output is correct
9 Correct 28 ms 32264 KB Output is correct
10 Correct 40 ms 35064 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 27480 KB Output is correct
2 Correct 6 ms 27228 KB Output is correct
3 Correct 6 ms 27228 KB Output is correct
4 Correct 7 ms 27544 KB Output is correct
5 Correct 5 ms 27228 KB Output is correct
6 Correct 6 ms 27228 KB Output is correct
7 Correct 6 ms 27228 KB Output is correct
8 Correct 6 ms 27228 KB Output is correct
9 Correct 6 ms 27228 KB Output is correct
10 Correct 6 ms 27320 KB Output is correct
11 Correct 6 ms 27228 KB Output is correct
12 Correct 7 ms 27484 KB Output is correct
13 Correct 7 ms 27320 KB Output is correct
14 Correct 8 ms 27484 KB Output is correct
15 Correct 8 ms 27780 KB Output is correct
16 Correct 8 ms 27484 KB Output is correct
17 Correct 7 ms 27480 KB Output is correct
18 Correct 8 ms 27480 KB Output is correct
19 Correct 100 ms 43348 KB Output is correct
20 Correct 99 ms 43348 KB Output is correct
21 Correct 89 ms 42576 KB Output is correct
22 Correct 94 ms 42528 KB Output is correct
23 Correct 95 ms 42996 KB Output is correct
24 Correct 79 ms 41676 KB Output is correct
25 Correct 82 ms 41808 KB Output is correct
26 Correct 86 ms 42064 KB Output is correct
27 Correct 87 ms 42156 KB Output is correct
28 Correct 90 ms 42252 KB Output is correct
29 Correct 94 ms 42416 KB Output is correct
30 Correct 97 ms 42580 KB Output is correct
31 Correct 100 ms 42492 KB Output is correct
32 Correct 100 ms 42540 KB Output is correct
33 Correct 97 ms 42376 KB Output is correct
34 Correct 77 ms 41300 KB Output is correct
35 Correct 75 ms 41300 KB Output is correct
36 Correct 74 ms 41152 KB Output is correct
37 Correct 75 ms 41044 KB Output is correct
38 Correct 75 ms 41296 KB Output is correct
39 Correct 89 ms 40972 KB Output is correct
40 Correct 74 ms 39684 KB Output is correct
41 Correct 84 ms 40452 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 27480 KB Output is correct
2 Correct 6 ms 27228 KB Output is correct
3 Correct 6 ms 27228 KB Output is correct
4 Correct 7 ms 27544 KB Output is correct
5 Correct 5 ms 27228 KB Output is correct
6 Correct 6 ms 27228 KB Output is correct
7 Correct 6 ms 27228 KB Output is correct
8 Correct 6 ms 27228 KB Output is correct
9 Correct 6 ms 27228 KB Output is correct
10 Correct 6 ms 27320 KB Output is correct
11 Correct 6 ms 27228 KB Output is correct
12 Correct 7 ms 27484 KB Output is correct
13 Correct 7 ms 27320 KB Output is correct
14 Correct 8 ms 27484 KB Output is correct
15 Correct 8 ms 27780 KB Output is correct
16 Correct 8 ms 27484 KB Output is correct
17 Correct 7 ms 27480 KB Output is correct
18 Correct 8 ms 27480 KB Output is correct
19 Correct 643 ms 92396 KB Output is correct
20 Correct 674 ms 93652 KB Output is correct
21 Correct 655 ms 93340 KB Output is correct
22 Correct 643 ms 93464 KB Output is correct
23 Correct 660 ms 91276 KB Output is correct
24 Correct 53 ms 35864 KB Output is correct
25 Correct 42 ms 35828 KB Output is correct
26 Correct 41 ms 35408 KB Output is correct
27 Correct 43 ms 35664 KB Output is correct
28 Correct 42 ms 35664 KB Output is correct
29 Correct 36 ms 35412 KB Output is correct
30 Correct 35 ms 35152 KB Output is correct
31 Correct 41 ms 35092 KB Output is correct
32 Correct 28 ms 32264 KB Output is correct
33 Correct 40 ms 35064 KB Output is correct
34 Correct 100 ms 43348 KB Output is correct
35 Correct 99 ms 43348 KB Output is correct
36 Correct 89 ms 42576 KB Output is correct
37 Correct 94 ms 42528 KB Output is correct
38 Correct 95 ms 42996 KB Output is correct
39 Correct 79 ms 41676 KB Output is correct
40 Correct 82 ms 41808 KB Output is correct
41 Correct 86 ms 42064 KB Output is correct
42 Correct 87 ms 42156 KB Output is correct
43 Correct 90 ms 42252 KB Output is correct
44 Correct 94 ms 42416 KB Output is correct
45 Correct 97 ms 42580 KB Output is correct
46 Correct 100 ms 42492 KB Output is correct
47 Correct 100 ms 42540 KB Output is correct
48 Correct 97 ms 42376 KB Output is correct
49 Correct 77 ms 41300 KB Output is correct
50 Correct 75 ms 41300 KB Output is correct
51 Correct 74 ms 41152 KB Output is correct
52 Correct 75 ms 41044 KB Output is correct
53 Correct 75 ms 41296 KB Output is correct
54 Correct 89 ms 40972 KB Output is correct
55 Correct 74 ms 39684 KB Output is correct
56 Correct 84 ms 40452 KB Output is correct
57 Correct 643 ms 93732 KB Output is correct
58 Correct 680 ms 93676 KB Output is correct
59 Correct 626 ms 92060 KB Output is correct
60 Correct 626 ms 92412 KB Output is correct
61 Correct 561 ms 92184 KB Output is correct
62 Correct 621 ms 91820 KB Output is correct
63 Correct 386 ms 86856 KB Output is correct
64 Correct 385 ms 86784 KB Output is correct
65 Correct 522 ms 89764 KB Output is correct
66 Correct 527 ms 90452 KB Output is correct
67 Correct 539 ms 90196 KB Output is correct
68 Correct 592 ms 91680 KB Output is correct
69 Correct 594 ms 91528 KB Output is correct
70 Correct 599 ms 91268 KB Output is correct
71 Correct 587 ms 91220 KB Output is correct
72 Correct 575 ms 91220 KB Output is correct
73 Correct 354 ms 82660 KB Output is correct
74 Correct 354 ms 83452 KB Output is correct
75 Correct 360 ms 82808 KB Output is correct
76 Correct 355 ms 82772 KB Output is correct
77 Correct 354 ms 82516 KB Output is correct
78 Correct 522 ms 84408 KB Output is correct
79 Correct 414 ms 74712 KB Output is correct
80 Correct 500 ms 81788 KB Output is correct