답안 #743794

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
743794 2023-05-18T02:28:34 Z JellyTheOctopus Exhibition (JOI19_ho_t2) C++17
100 / 100
238 ms 5340 KB
#include <bits/stdc++.h>
using namespace std;

#define f first
#define s second

int N, M;
vector<pair<int, int>> pictures;
vector<int> frames;

bool check(int x) {
	int j = 1;
	int prev = 0;
	bool flag = true;
	priority_queue<int, vector<int>, greater<int>> pq;
	for (int i = M-x+1; i <= M; i++) {
		while (j <= N && pictures[j].f <= frames[i]) {
			pq.push(pictures[j].s);
			j++;
		}
		if (pq.empty()) {
			flag = false;
		}
		else {
			while (!pq.empty() && (pq.top() < prev)) {
				pq.pop();
			}
			if (pq.empty()) {
				flag = false;
			}
			else {
				prev = pq.top();
				pq.pop();
			}
		}
	}
	return flag;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cin >> N >> M;
	pictures.resize(N+1);
	frames.resize(M+1);
	for (int i = 1; i <= N; i++) {
		cin >> pictures[i].f >> pictures[i].s;
	}
	for (int i = 1; i <= M; i++) {
		cin >> frames[i];
	}
	sort(pictures.begin(), pictures.end());
	sort(frames.begin(), frames.end());
	int high = min(N, M);
	int low = 1;
	int ans = low-1;
	while (low <= high) {
		int mid = (low+high)/2;
		if (check(mid)) {
			ans = mid;
			low = mid+1;
		}
		else {
			high = mid-1;
		}
	}
	cout << ans << "\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 316 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 324 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 324 KB Output is correct
8 Correct 1 ms 316 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 320 KB Output is correct
19 Correct 0 ms 320 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 316 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 324 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 324 KB Output is correct
8 Correct 1 ms 316 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 320 KB Output is correct
19 Correct 0 ms 320 KB Output is correct
20 Correct 2 ms 364 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 328 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 2 ms 336 KB Output is correct
26 Correct 2 ms 364 KB Output is correct
27 Correct 1 ms 328 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 368 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 2 ms 336 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 212 KB Output is correct
34 Correct 1 ms 340 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 2 ms 340 KB Output is correct
37 Correct 2 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 316 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 324 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 324 KB Output is correct
8 Correct 1 ms 316 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 320 KB Output is correct
19 Correct 0 ms 320 KB Output is correct
20 Correct 2 ms 364 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 328 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 2 ms 336 KB Output is correct
26 Correct 2 ms 364 KB Output is correct
27 Correct 1 ms 328 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 368 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 2 ms 336 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 212 KB Output is correct
34 Correct 1 ms 340 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 2 ms 340 KB Output is correct
37 Correct 2 ms 340 KB Output is correct
38 Correct 102 ms 4688 KB Output is correct
39 Correct 92 ms 4688 KB Output is correct
40 Correct 151 ms 4712 KB Output is correct
41 Correct 130 ms 4716 KB Output is correct
42 Correct 42 ms 4296 KB Output is correct
43 Correct 42 ms 4304 KB Output is correct
44 Correct 153 ms 4824 KB Output is correct
45 Correct 238 ms 5008 KB Output is correct
46 Correct 183 ms 4936 KB Output is correct
47 Correct 205 ms 4612 KB Output is correct
48 Correct 171 ms 4724 KB Output is correct
49 Correct 164 ms 4004 KB Output is correct
50 Correct 136 ms 4016 KB Output is correct
51 Correct 46 ms 4396 KB Output is correct
52 Correct 47 ms 4296 KB Output is correct
53 Correct 43 ms 4300 KB Output is correct
54 Correct 146 ms 5340 KB Output is correct
55 Correct 98 ms 4780 KB Output is correct
56 Correct 27 ms 3404 KB Output is correct
57 Correct 17 ms 1620 KB Output is correct
58 Correct 32 ms 3896 KB Output is correct
59 Correct 46 ms 3936 KB Output is correct
60 Correct 17 ms 1672 KB Output is correct
61 Correct 80 ms 2840 KB Output is correct
62 Correct 216 ms 4812 KB Output is correct
63 Correct 215 ms 4792 KB Output is correct
64 Correct 235 ms 4852 KB Output is correct
65 Correct 222 ms 4792 KB Output is correct
66 Correct 214 ms 4776 KB Output is correct
67 Correct 229 ms 4784 KB Output is correct
68 Correct 218 ms 4788 KB Output is correct
69 Correct 223 ms 4792 KB Output is correct
70 Correct 219 ms 4988 KB Output is correct
71 Correct 210 ms 4780 KB Output is correct
72 Correct 188 ms 4800 KB Output is correct
73 Correct 190 ms 4868 KB Output is correct