답안 #524653

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
524653 2022-02-09T18:15:35 Z thomas_li Exhibition (JOI19_ho_t2) C++17
100 / 100
281 ms 5312 KB
#include <bits/stdc++.h>
using namespace std;
const int MM = 1e5+5;
int main(){
	cin.tie(0)->sync_with_stdio(0);
	int n,m,ans = 0; cin >> n >> m;
	vector<array<int,2>> a; vector<int> b;
	for(int i = 0; i < n; i++){
		int s,v; cin >> s >> v;
		a.push_back({s,v});
	}
	for(int i = 0; i < m; i++){
		int c; cin >> c;
		b.emplace_back(c);
	}
	sort(b.begin(),b.end());
	sort(a.begin(),a.end());
	auto solve = [&](int st){
		priority_queue<int,vector<int>,greater<>> q;	
		for(int i = st, j = 0,lst = 0; i < m; i++){
			while(j < n && a[j][0] <= b[i]){
				if(lst <= a[j][1]) q.push(a[j][1]);
				j++;
			}
			if(q.empty()) return 0;
			lst = q.top();
			q.pop();
		}
		return 1;
	};
    int lo = 0, hi = m-1;
    while(lo < hi){
        int mid = (lo+hi)/2;
        if(solve(mid)) hi = mid;
        else lo = mid+1;
    }
    if(solve(lo)) cout << m-lo << "\n";
    else cout << "0\n";
}
// if ans = k, we should take k biggest frames
// we should put min value that fits in left frame, min value that fits into second left, ...

Compilation message

joi2019_ho_t2.cpp: In function 'int main()':
joi2019_ho_t2.cpp:6:10: warning: unused variable 'ans' [-Wunused-variable]
    6 |  int n,m,ans = 0; cin >> n >> m;
      |          ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 308 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 312 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 304 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 1 ms 316 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 308 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 312 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 304 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 1 ms 316 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
20 Correct 1 ms 328 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 2 ms 332 KB Output is correct
25 Correct 2 ms 332 KB Output is correct
26 Correct 3 ms 332 KB Output is correct
27 Correct 1 ms 316 KB Output is correct
28 Correct 1 ms 332 KB Output is correct
29 Correct 1 ms 324 KB Output is correct
30 Correct 1 ms 332 KB Output is correct
31 Correct 2 ms 320 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
33 Correct 1 ms 332 KB Output is correct
34 Correct 1 ms 332 KB Output is correct
35 Correct 1 ms 204 KB Output is correct
36 Correct 1 ms 332 KB Output is correct
37 Correct 2 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 308 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 312 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 304 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 1 ms 316 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
20 Correct 1 ms 328 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 2 ms 332 KB Output is correct
25 Correct 2 ms 332 KB Output is correct
26 Correct 3 ms 332 KB Output is correct
27 Correct 1 ms 316 KB Output is correct
28 Correct 1 ms 332 KB Output is correct
29 Correct 1 ms 324 KB Output is correct
30 Correct 1 ms 332 KB Output is correct
31 Correct 2 ms 320 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
33 Correct 1 ms 332 KB Output is correct
34 Correct 1 ms 332 KB Output is correct
35 Correct 1 ms 204 KB Output is correct
36 Correct 1 ms 332 KB Output is correct
37 Correct 2 ms 332 KB Output is correct
38 Correct 117 ms 4896 KB Output is correct
39 Correct 96 ms 4848 KB Output is correct
40 Correct 159 ms 4924 KB Output is correct
41 Correct 142 ms 4904 KB Output is correct
42 Correct 47 ms 4780 KB Output is correct
43 Correct 50 ms 4872 KB Output is correct
44 Correct 125 ms 5160 KB Output is correct
45 Correct 281 ms 5208 KB Output is correct
46 Correct 220 ms 5140 KB Output is correct
47 Correct 202 ms 4724 KB Output is correct
48 Correct 177 ms 4780 KB Output is correct
49 Correct 177 ms 3996 KB Output is correct
50 Correct 142 ms 4060 KB Output is correct
51 Correct 52 ms 4968 KB Output is correct
52 Correct 53 ms 4864 KB Output is correct
53 Correct 47 ms 4732 KB Output is correct
54 Correct 162 ms 5312 KB Output is correct
55 Correct 88 ms 4840 KB Output is correct
56 Correct 33 ms 3440 KB Output is correct
57 Correct 19 ms 1840 KB Output is correct
58 Correct 41 ms 3956 KB Output is correct
59 Correct 56 ms 3896 KB Output is correct
60 Correct 19 ms 1816 KB Output is correct
61 Correct 97 ms 2872 KB Output is correct
62 Correct 197 ms 4900 KB Output is correct
63 Correct 207 ms 4900 KB Output is correct
64 Correct 182 ms 4900 KB Output is correct
65 Correct 190 ms 4856 KB Output is correct
66 Correct 184 ms 4876 KB Output is correct
67 Correct 194 ms 5020 KB Output is correct
68 Correct 185 ms 4800 KB Output is correct
69 Correct 175 ms 4896 KB Output is correct
70 Correct 186 ms 4904 KB Output is correct
71 Correct 156 ms 4896 KB Output is correct
72 Correct 137 ms 4912 KB Output is correct
73 Correct 151 ms 4892 KB Output is correct