답안 #343354

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
343354 2021-01-03T18:19:22 Z jenkinsser Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++17
100 / 100
1012 ms 71952 KB
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define pii pair<int,int>
#define N 1000005
#define INF 1e9+5
#define sp " "
#define endl "\n"
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);
#define all(x) (x).begin(),(x).end()
#define ll long long
using namespace std;

int a[N], ans[N];

vector<pair<pii,int>> q[N];

int f[N];
void upd(int i, int j) {
	i = N - 1 - i;
	while (i < N) {
		f[i] = max(f[i], j);
		i |= i + 1;
	}
}
int get(int i) {
	i = N - 1 - i;
	int j = 0;
	while (i >= 0) {
		j = max(j, f[i]);
		i &= i + 1;
		i--;
	}
	return j;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	int n, m;
	cin >> n >> m;
	for (int i = 1 ; i <= n ; ++ i) cin >> a[i];
	for (int i = 1 ; i <= m ; ++ i) {
		int l, r, k;
		cin >> l >> r >> k;
		q[r].push_back({{l, k}, i});
	}
	stack<int> s;
	for (int i = 1 ; i <= n ; ++ i) {
		while (s.size() && a[s.top()] <= a[i]) s.pop();
		if (s.size()) {
			int j = s.top();
			upd(j, a[i] + a[j]);
		}
		s.push(i);
		for (int j=0;j<q[i].size();j++) {
            pair<pii,int> p=q[i][j];
			ans[p.nd] = (get(p.st.st) <= p.st.nd);
		}
	}
	for (int i = 1 ; i <= m ; ++ i) cout << ans[i] << "\n";
}

Compilation message

sortbooks.cpp: In function 'int main()':
sortbooks.cpp:58:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<std::pair<int, int>, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |   for (int j=0;j<q[i].size();j++) {
      |                ~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 23788 KB Output is correct
2 Correct 15 ms 23788 KB Output is correct
3 Correct 15 ms 23916 KB Output is correct
4 Correct 15 ms 23916 KB Output is correct
5 Correct 15 ms 23916 KB Output is correct
6 Correct 15 ms 23916 KB Output is correct
7 Correct 15 ms 23916 KB Output is correct
8 Correct 15 ms 23916 KB Output is correct
9 Correct 15 ms 23916 KB Output is correct
10 Correct 15 ms 23916 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 23788 KB Output is correct
2 Correct 15 ms 23788 KB Output is correct
3 Correct 15 ms 23916 KB Output is correct
4 Correct 15 ms 23916 KB Output is correct
5 Correct 15 ms 23916 KB Output is correct
6 Correct 15 ms 23916 KB Output is correct
7 Correct 15 ms 23916 KB Output is correct
8 Correct 15 ms 23916 KB Output is correct
9 Correct 15 ms 23916 KB Output is correct
10 Correct 15 ms 23916 KB Output is correct
11 Correct 17 ms 23916 KB Output is correct
12 Correct 17 ms 23916 KB Output is correct
13 Correct 18 ms 23916 KB Output is correct
14 Correct 19 ms 24044 KB Output is correct
15 Correct 18 ms 24044 KB Output is correct
16 Correct 18 ms 24044 KB Output is correct
17 Correct 17 ms 24044 KB Output is correct
18 Correct 18 ms 24044 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 992 ms 59500 KB Output is correct
2 Correct 1008 ms 59860 KB Output is correct
3 Correct 1012 ms 60392 KB Output is correct
4 Correct 984 ms 59776 KB Output is correct
5 Correct 924 ms 56044 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 83 ms 28268 KB Output is correct
2 Correct 76 ms 29036 KB Output is correct
3 Correct 74 ms 29036 KB Output is correct
4 Correct 77 ms 28908 KB Output is correct
5 Correct 75 ms 28908 KB Output is correct
6 Correct 66 ms 28396 KB Output is correct
7 Correct 64 ms 28396 KB Output is correct
8 Correct 73 ms 28452 KB Output is correct
9 Correct 55 ms 27300 KB Output is correct
10 Correct 71 ms 28452 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 23788 KB Output is correct
2 Correct 15 ms 23788 KB Output is correct
3 Correct 15 ms 23916 KB Output is correct
4 Correct 15 ms 23916 KB Output is correct
5 Correct 15 ms 23916 KB Output is correct
6 Correct 15 ms 23916 KB Output is correct
7 Correct 15 ms 23916 KB Output is correct
8 Correct 15 ms 23916 KB Output is correct
9 Correct 15 ms 23916 KB Output is correct
10 Correct 15 ms 23916 KB Output is correct
11 Correct 17 ms 23916 KB Output is correct
12 Correct 17 ms 23916 KB Output is correct
13 Correct 18 ms 23916 KB Output is correct
14 Correct 19 ms 24044 KB Output is correct
15 Correct 18 ms 24044 KB Output is correct
16 Correct 18 ms 24044 KB Output is correct
17 Correct 17 ms 24044 KB Output is correct
18 Correct 18 ms 24044 KB Output is correct
19 Correct 177 ms 31468 KB Output is correct
20 Correct 184 ms 37612 KB Output is correct
21 Correct 152 ms 36844 KB Output is correct
22 Correct 153 ms 36776 KB Output is correct
23 Correct 162 ms 36844 KB Output is correct
24 Correct 141 ms 35820 KB Output is correct
25 Correct 140 ms 35820 KB Output is correct
26 Correct 168 ms 36380 KB Output is correct
27 Correct 161 ms 36204 KB Output is correct
28 Correct 167 ms 36332 KB Output is correct
29 Correct 182 ms 36800 KB Output is correct
30 Correct 170 ms 36716 KB Output is correct
31 Correct 173 ms 36588 KB Output is correct
32 Correct 172 ms 36716 KB Output is correct
33 Correct 173 ms 36844 KB Output is correct
34 Correct 136 ms 35436 KB Output is correct
35 Correct 143 ms 35488 KB Output is correct
36 Correct 133 ms 35180 KB Output is correct
37 Correct 131 ms 35180 KB Output is correct
38 Correct 142 ms 35564 KB Output is correct
39 Correct 162 ms 35240 KB Output is correct
40 Correct 142 ms 33764 KB Output is correct
41 Correct 157 ms 34524 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 23788 KB Output is correct
2 Correct 15 ms 23788 KB Output is correct
3 Correct 15 ms 23916 KB Output is correct
4 Correct 15 ms 23916 KB Output is correct
5 Correct 15 ms 23916 KB Output is correct
6 Correct 15 ms 23916 KB Output is correct
7 Correct 15 ms 23916 KB Output is correct
8 Correct 15 ms 23916 KB Output is correct
9 Correct 15 ms 23916 KB Output is correct
10 Correct 15 ms 23916 KB Output is correct
11 Correct 17 ms 23916 KB Output is correct
12 Correct 17 ms 23916 KB Output is correct
13 Correct 18 ms 23916 KB Output is correct
14 Correct 19 ms 24044 KB Output is correct
15 Correct 18 ms 24044 KB Output is correct
16 Correct 18 ms 24044 KB Output is correct
17 Correct 17 ms 24044 KB Output is correct
18 Correct 18 ms 24044 KB Output is correct
19 Correct 992 ms 59500 KB Output is correct
20 Correct 1008 ms 59860 KB Output is correct
21 Correct 1012 ms 60392 KB Output is correct
22 Correct 984 ms 59776 KB Output is correct
23 Correct 924 ms 56044 KB Output is correct
24 Correct 83 ms 28268 KB Output is correct
25 Correct 76 ms 29036 KB Output is correct
26 Correct 74 ms 29036 KB Output is correct
27 Correct 77 ms 28908 KB Output is correct
28 Correct 75 ms 28908 KB Output is correct
29 Correct 66 ms 28396 KB Output is correct
30 Correct 64 ms 28396 KB Output is correct
31 Correct 73 ms 28452 KB Output is correct
32 Correct 55 ms 27300 KB Output is correct
33 Correct 71 ms 28452 KB Output is correct
34 Correct 177 ms 31468 KB Output is correct
35 Correct 184 ms 37612 KB Output is correct
36 Correct 152 ms 36844 KB Output is correct
37 Correct 153 ms 36776 KB Output is correct
38 Correct 162 ms 36844 KB Output is correct
39 Correct 141 ms 35820 KB Output is correct
40 Correct 140 ms 35820 KB Output is correct
41 Correct 168 ms 36380 KB Output is correct
42 Correct 161 ms 36204 KB Output is correct
43 Correct 167 ms 36332 KB Output is correct
44 Correct 182 ms 36800 KB Output is correct
45 Correct 170 ms 36716 KB Output is correct
46 Correct 173 ms 36588 KB Output is correct
47 Correct 172 ms 36716 KB Output is correct
48 Correct 173 ms 36844 KB Output is correct
49 Correct 136 ms 35436 KB Output is correct
50 Correct 143 ms 35488 KB Output is correct
51 Correct 133 ms 35180 KB Output is correct
52 Correct 131 ms 35180 KB Output is correct
53 Correct 142 ms 35564 KB Output is correct
54 Correct 162 ms 35240 KB Output is correct
55 Correct 142 ms 33764 KB Output is correct
56 Correct 157 ms 34524 KB Output is correct
57 Correct 991 ms 71952 KB Output is correct
58 Correct 994 ms 65776 KB Output is correct
59 Correct 943 ms 64236 KB Output is correct
60 Correct 949 ms 63980 KB Output is correct
61 Correct 949 ms 64108 KB Output is correct
62 Correct 936 ms 64108 KB Output is correct
63 Correct 657 ms 61224 KB Output is correct
64 Correct 664 ms 61292 KB Output is correct
65 Correct 854 ms 60012 KB Output is correct
66 Correct 846 ms 60012 KB Output is correct
67 Correct 874 ms 60268 KB Output is correct
68 Correct 908 ms 61804 KB Output is correct
69 Correct 949 ms 61548 KB Output is correct
70 Correct 921 ms 61484 KB Output is correct
71 Correct 898 ms 61292 KB Output is correct
72 Correct 903 ms 61292 KB Output is correct
73 Correct 576 ms 58476 KB Output is correct
74 Correct 604 ms 58724 KB Output is correct
75 Correct 575 ms 58860 KB Output is correct
76 Correct 577 ms 58732 KB Output is correct
77 Correct 577 ms 58348 KB Output is correct
78 Correct 813 ms 62756 KB Output is correct
79 Correct 660 ms 49336 KB Output is correct
80 Correct 796 ms 61976 KB Output is correct