답안 #124714

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
124714 2019-07-03T18:33:18 Z Noam527 Exhibition (JOI19_ho_t2) C++17
100 / 100
293 ms 5416 KB
#include <bits/stdc++.h>
#define finish(x) return cout << x << endl, 0
typedef long long ll;
typedef long double ldb;
const int md = 1e9 + 7;
const ll inf = 1e18;
const int OO = 1;
const int OOO = 1;
using namespace std;

int n, m;
vector<pair<int, int>> a;
vector<int> b;

bool can(int x) {
	priority_queue<int, vector<int>, greater<int>> Q;
	int lst = -1, nxt = 0;
	for (int i = m - x; i < m; i++) {
		while (nxt < a.size() && a[nxt].first <= b[i]) {
			if (a[nxt].second >= lst) Q.push(a[nxt].second);
			nxt++;
		}
		if (!Q.size()) return false;
		lst = Q.top();
		Q.pop();
	}
	return true;
}

int main() {
	ios::sync_with_stdio(0), cin.tie(0);
	cin >> n >> m;
	a.resize(n);
	for (auto &i : a) cin >> i.first >> i.second;
	sort(a.begin(), a.end());
	b.resize(m);
	for (auto &i : b) cin >> i;
	sort(b.begin(), b.end());
	int lo = 0, hi = min(n, m), mid;
	while (lo < hi) {
		mid = (lo + hi + 1) / 2;
		if (can(mid)) lo = mid;
		else hi = mid - 1;
	}
	finish(lo);
}

Compilation message

joi2019_ho_t2.cpp: In function 'bool can(int)':
joi2019_ho_t2.cpp:19:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   while (nxt < a.size() && a[nxt].first <= b[i]) {
          ~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 3 ms 376 KB Output is correct
21 Correct 3 ms 424 KB Output is correct
22 Correct 3 ms 376 KB Output is correct
23 Correct 3 ms 376 KB Output is correct
24 Correct 3 ms 424 KB Output is correct
25 Correct 4 ms 376 KB Output is correct
26 Correct 3 ms 376 KB Output is correct
27 Correct 2 ms 376 KB Output is correct
28 Correct 3 ms 376 KB Output is correct
29 Correct 4 ms 376 KB Output is correct
30 Correct 3 ms 376 KB Output is correct
31 Correct 3 ms 376 KB Output is correct
32 Correct 3 ms 376 KB Output is correct
33 Correct 2 ms 376 KB Output is correct
34 Correct 3 ms 376 KB Output is correct
35 Correct 2 ms 376 KB Output is correct
36 Correct 3 ms 376 KB Output is correct
37 Correct 3 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 3 ms 376 KB Output is correct
21 Correct 3 ms 424 KB Output is correct
22 Correct 3 ms 376 KB Output is correct
23 Correct 3 ms 376 KB Output is correct
24 Correct 3 ms 424 KB Output is correct
25 Correct 4 ms 376 KB Output is correct
26 Correct 3 ms 376 KB Output is correct
27 Correct 2 ms 376 KB Output is correct
28 Correct 3 ms 376 KB Output is correct
29 Correct 4 ms 376 KB Output is correct
30 Correct 3 ms 376 KB Output is correct
31 Correct 3 ms 376 KB Output is correct
32 Correct 3 ms 376 KB Output is correct
33 Correct 2 ms 376 KB Output is correct
34 Correct 3 ms 376 KB Output is correct
35 Correct 2 ms 376 KB Output is correct
36 Correct 3 ms 376 KB Output is correct
37 Correct 3 ms 376 KB Output is correct
38 Correct 138 ms 4852 KB Output is correct
39 Correct 128 ms 4788 KB Output is correct
40 Correct 191 ms 4880 KB Output is correct
41 Correct 163 ms 4856 KB Output is correct
42 Correct 62 ms 4472 KB Output is correct
43 Correct 62 ms 4472 KB Output is correct
44 Correct 138 ms 4968 KB Output is correct
45 Correct 293 ms 5112 KB Output is correct
46 Correct 243 ms 4988 KB Output is correct
47 Correct 231 ms 4600 KB Output is correct
48 Correct 201 ms 4600 KB Output is correct
49 Correct 204 ms 4200 KB Output is correct
50 Correct 176 ms 4188 KB Output is correct
51 Correct 62 ms 4472 KB Output is correct
52 Correct 62 ms 4472 KB Output is correct
53 Correct 63 ms 4472 KB Output is correct
54 Correct 197 ms 5416 KB Output is correct
55 Correct 112 ms 4860 KB Output is correct
56 Correct 41 ms 3448 KB Output is correct
57 Correct 25 ms 1784 KB Output is correct
58 Correct 48 ms 4068 KB Output is correct
59 Correct 65 ms 4072 KB Output is correct
60 Correct 25 ms 1784 KB Output is correct
61 Correct 95 ms 2948 KB Output is correct
62 Correct 209 ms 5056 KB Output is correct
63 Correct 207 ms 4860 KB Output is correct
64 Correct 217 ms 4920 KB Output is correct
65 Correct 226 ms 4976 KB Output is correct
66 Correct 214 ms 5012 KB Output is correct
67 Correct 217 ms 4892 KB Output is correct
68 Correct 208 ms 4908 KB Output is correct
69 Correct 217 ms 4912 KB Output is correct
70 Correct 209 ms 4940 KB Output is correct
71 Correct 199 ms 4952 KB Output is correct
72 Correct 177 ms 4988 KB Output is correct
73 Correct 189 ms 4908 KB Output is correct