답안 #498966

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
498966 2021-12-26T20:06:17 Z NachoLibre Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++17
100 / 100
749 ms 78816 KB
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
using namespace std;

const int inf = 2e9;

vector<int> f;
void upd(int i, int x) {
	for(; i < sz(f); i += (i & -i)) {
		f[i] = max(f[i], x);
	}
}

int maxx(int i) {
	int x = 0;
	for(; i; i -= (i & -i)) {
		x = max(x, f[i]);
	}
	return x;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	f = vector<int>(n + 1, 0);
	int a[n + 1], b[n + 1];
	memset(b, 0, sizeof b);
	vector<pair<int, int> > v(1, {inf, 0});
	vector<int> u[n + 1];
	for(int i = 1; i <= n; ++i) {
		cin >> a[i];
		while(v.back().first <= a[i]) { v.pop_back(); }
		b[i] = v.back().second;
		v.push_back({a[i], i});
		u[b[i]].push_back(i);
	}
	vector<array<int, 4> > q;
	for(int i = 1; i <= m; ++i) {
		int l, r, k;
		cin >> l >> r >> k;
		q.push_back({l, r, k, i});
	}
	sort(all(q));
	reverse(all(q));
	int on = n + 1;
	int fp[m + 1];
	for(auto x : q) {
		while(on > x[0]) {
			on -= 1;
			for(int i : u[on]) {
				upd(i, a[on] + a[i]);
			}
		}
		fp[x[3]] = x[2] >= maxx(x[1]);
	}
	for(int i = 1; i <= m; ++i) {
		cout << fp[i] << "\n";
	}
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 320 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 320 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 2 ms 488 KB Output is correct
12 Correct 3 ms 716 KB Output is correct
13 Correct 3 ms 716 KB Output is correct
14 Correct 4 ms 844 KB Output is correct
15 Correct 4 ms 844 KB Output is correct
16 Correct 4 ms 840 KB Output is correct
17 Correct 3 ms 716 KB Output is correct
18 Correct 3 ms 820 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 697 ms 75224 KB Output is correct
2 Correct 694 ms 75152 KB Output is correct
3 Correct 689 ms 75020 KB Output is correct
4 Correct 682 ms 75004 KB Output is correct
5 Correct 617 ms 62800 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 58 ms 8416 KB Output is correct
2 Correct 60 ms 8500 KB Output is correct
3 Correct 54 ms 7292 KB Output is correct
4 Correct 48 ms 7276 KB Output is correct
5 Correct 50 ms 7188 KB Output is correct
6 Correct 50 ms 7396 KB Output is correct
7 Correct 63 ms 7428 KB Output is correct
8 Correct 50 ms 7312 KB Output is correct
9 Correct 40 ms 3308 KB Output is correct
10 Correct 53 ms 7340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 320 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 2 ms 488 KB Output is correct
12 Correct 3 ms 716 KB Output is correct
13 Correct 3 ms 716 KB Output is correct
14 Correct 4 ms 844 KB Output is correct
15 Correct 4 ms 844 KB Output is correct
16 Correct 4 ms 840 KB Output is correct
17 Correct 3 ms 716 KB Output is correct
18 Correct 3 ms 820 KB Output is correct
19 Correct 147 ms 16660 KB Output is correct
20 Correct 143 ms 16528 KB Output is correct
21 Correct 143 ms 17336 KB Output is correct
22 Correct 143 ms 15912 KB Output is correct
23 Correct 134 ms 15776 KB Output is correct
24 Correct 141 ms 13396 KB Output is correct
25 Correct 117 ms 13356 KB Output is correct
26 Correct 122 ms 13336 KB Output is correct
27 Correct 123 ms 13348 KB Output is correct
28 Correct 118 ms 13256 KB Output is correct
29 Correct 119 ms 13368 KB Output is correct
30 Correct 124 ms 13356 KB Output is correct
31 Correct 117 ms 13372 KB Output is correct
32 Correct 124 ms 13340 KB Output is correct
33 Correct 118 ms 13272 KB Output is correct
34 Correct 127 ms 13508 KB Output is correct
35 Correct 132 ms 13356 KB Output is correct
36 Correct 115 ms 13312 KB Output is correct
37 Correct 128 ms 13292 KB Output is correct
38 Correct 161 ms 13244 KB Output is correct
39 Correct 113 ms 14136 KB Output is correct
40 Correct 110 ms 10724 KB Output is correct
41 Correct 124 ms 13672 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 320 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 2 ms 488 KB Output is correct
12 Correct 3 ms 716 KB Output is correct
13 Correct 3 ms 716 KB Output is correct
14 Correct 4 ms 844 KB Output is correct
15 Correct 4 ms 844 KB Output is correct
16 Correct 4 ms 840 KB Output is correct
17 Correct 3 ms 716 KB Output is correct
18 Correct 3 ms 820 KB Output is correct
19 Correct 697 ms 75224 KB Output is correct
20 Correct 694 ms 75152 KB Output is correct
21 Correct 689 ms 75020 KB Output is correct
22 Correct 682 ms 75004 KB Output is correct
23 Correct 617 ms 62800 KB Output is correct
24 Correct 58 ms 8416 KB Output is correct
25 Correct 60 ms 8500 KB Output is correct
26 Correct 54 ms 7292 KB Output is correct
27 Correct 48 ms 7276 KB Output is correct
28 Correct 50 ms 7188 KB Output is correct
29 Correct 50 ms 7396 KB Output is correct
30 Correct 63 ms 7428 KB Output is correct
31 Correct 50 ms 7312 KB Output is correct
32 Correct 40 ms 3308 KB Output is correct
33 Correct 53 ms 7340 KB Output is correct
34 Correct 147 ms 16660 KB Output is correct
35 Correct 143 ms 16528 KB Output is correct
36 Correct 143 ms 17336 KB Output is correct
37 Correct 143 ms 15912 KB Output is correct
38 Correct 134 ms 15776 KB Output is correct
39 Correct 141 ms 13396 KB Output is correct
40 Correct 117 ms 13356 KB Output is correct
41 Correct 122 ms 13336 KB Output is correct
42 Correct 123 ms 13348 KB Output is correct
43 Correct 118 ms 13256 KB Output is correct
44 Correct 119 ms 13368 KB Output is correct
45 Correct 124 ms 13356 KB Output is correct
46 Correct 117 ms 13372 KB Output is correct
47 Correct 124 ms 13340 KB Output is correct
48 Correct 118 ms 13272 KB Output is correct
49 Correct 127 ms 13508 KB Output is correct
50 Correct 132 ms 13356 KB Output is correct
51 Correct 115 ms 13312 KB Output is correct
52 Correct 128 ms 13292 KB Output is correct
53 Correct 161 ms 13244 KB Output is correct
54 Correct 113 ms 14136 KB Output is correct
55 Correct 110 ms 10724 KB Output is correct
56 Correct 124 ms 13672 KB Output is correct
57 Correct 734 ms 74388 KB Output is correct
58 Correct 706 ms 78724 KB Output is correct
59 Correct 698 ms 78816 KB Output is correct
60 Correct 698 ms 78692 KB Output is correct
61 Correct 719 ms 78660 KB Output is correct
62 Correct 749 ms 78668 KB Output is correct
63 Correct 620 ms 65940 KB Output is correct
64 Correct 633 ms 65856 KB Output is correct
65 Correct 593 ms 66536 KB Output is correct
66 Correct 612 ms 66276 KB Output is correct
67 Correct 617 ms 66444 KB Output is correct
68 Correct 631 ms 66348 KB Output is correct
69 Correct 613 ms 66556 KB Output is correct
70 Correct 637 ms 66556 KB Output is correct
71 Correct 615 ms 66432 KB Output is correct
72 Correct 609 ms 66456 KB Output is correct
73 Correct 593 ms 65696 KB Output is correct
74 Correct 629 ms 66108 KB Output is correct
75 Correct 606 ms 65628 KB Output is correct
76 Correct 608 ms 65716 KB Output is correct
77 Correct 600 ms 65676 KB Output is correct
78 Correct 587 ms 69544 KB Output is correct
79 Correct 496 ms 48020 KB Output is correct
80 Correct 571 ms 66932 KB Output is correct