답안 #208450

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
208450 2020-03-11T08:29:17 Z Siberian Exhibition (JOI19_ho_t2) C++14
100 / 100
277 ms 3188 KB
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
#define all(x) x.begin(), x.end()

template <typename T1, typename T2> inline void chkmin(T1 &x, const T2 & y) {if (x > y) x = y;}
template <typename T1, typename T2> inline void chkmax(T1 &x, const T2 & y) {if (x < y) x = y;}

struct event{
	int s, v;
	event () {}
	event(int _s, int _v) {
		s = _s, v = _v;
	}
};

bool operator<(const event & a, const event & b) {
	return tie(a.v, a.s) < tie(b.v, b.s);
}

int n, m;
vector<event> a;
vector<int> c;

void read() {
	cin >> n >> m;
	a.resize(n);
	for (auto &i : a) {
		cin >> i.s >> i.v;
	}
	sort(all(a));
	c.resize(m);
	for (auto &i : c) {
		cin >> i;
	}
	sort(all(c));
	reverse(all(c));
}

bool check(int cnt) {
	vector<int> fc;
	for (int i = 0; i < cnt; i++)
		fc.push_back(c[i]);
	reverse(all(fc));
	int mx = 0;
	for (auto i : a) {
		int have = mx;
		int min_pos = lower_bound(all(fc), i.s) - fc.begin();
		if (min_pos > have) continue;
		chkmax(mx, have + 1);
	}

	return mx >= cnt;
}

int ans;

void build() {
	vector<int> have;
	for (auto i : a) {
		have.push_back(i.s);
	}
	for (auto i : c) {
		have.push_back(i);
	}
	sort(all(have));
	have.resize(unique(all(have)) - have.begin());
	for (auto &i : a) {
		i.s = lower_bound(all(have), i.s) - have.begin();
	}
	for (auto &i : c) {
		i = lower_bound(all(have), i) - have.begin();
	}
}

void run() {
	build();
	int l = 0, r = min(n, m) + 1;
	while (l < r - 1) {
		int mid = (l + r) / 2;
		if (check(mid))
			l = mid;
		else
			r = mid;
	}
	ans = l;
}

void write() {
	cout << ans << endl;
}

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	read();
	run();
	write();
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 4 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 5 ms 504 KB Output is correct
12 Correct 5 ms 376 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 5 ms 376 KB Output is correct
15 Correct 5 ms 376 KB Output is correct
16 Correct 5 ms 376 KB Output is correct
17 Correct 5 ms 376 KB Output is correct
18 Correct 5 ms 376 KB Output is correct
19 Correct 5 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 4 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 5 ms 504 KB Output is correct
12 Correct 5 ms 376 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 5 ms 376 KB Output is correct
15 Correct 5 ms 376 KB Output is correct
16 Correct 5 ms 376 KB Output is correct
17 Correct 5 ms 376 KB Output is correct
18 Correct 5 ms 376 KB Output is correct
19 Correct 5 ms 376 KB Output is correct
20 Correct 6 ms 376 KB Output is correct
21 Correct 6 ms 376 KB Output is correct
22 Correct 6 ms 376 KB Output is correct
23 Correct 6 ms 376 KB Output is correct
24 Correct 6 ms 376 KB Output is correct
25 Correct 6 ms 376 KB Output is correct
26 Correct 6 ms 376 KB Output is correct
27 Correct 6 ms 376 KB Output is correct
28 Correct 6 ms 376 KB Output is correct
29 Correct 6 ms 376 KB Output is correct
30 Correct 6 ms 376 KB Output is correct
31 Correct 6 ms 376 KB Output is correct
32 Correct 5 ms 376 KB Output is correct
33 Correct 5 ms 376 KB Output is correct
34 Correct 6 ms 376 KB Output is correct
35 Correct 5 ms 376 KB Output is correct
36 Correct 6 ms 376 KB Output is correct
37 Correct 6 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 4 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 5 ms 504 KB Output is correct
12 Correct 5 ms 376 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 5 ms 376 KB Output is correct
15 Correct 5 ms 376 KB Output is correct
16 Correct 5 ms 376 KB Output is correct
17 Correct 5 ms 376 KB Output is correct
18 Correct 5 ms 376 KB Output is correct
19 Correct 5 ms 376 KB Output is correct
20 Correct 6 ms 376 KB Output is correct
21 Correct 6 ms 376 KB Output is correct
22 Correct 6 ms 376 KB Output is correct
23 Correct 6 ms 376 KB Output is correct
24 Correct 6 ms 376 KB Output is correct
25 Correct 6 ms 376 KB Output is correct
26 Correct 6 ms 376 KB Output is correct
27 Correct 6 ms 376 KB Output is correct
28 Correct 6 ms 376 KB Output is correct
29 Correct 6 ms 376 KB Output is correct
30 Correct 6 ms 376 KB Output is correct
31 Correct 6 ms 376 KB Output is correct
32 Correct 5 ms 376 KB Output is correct
33 Correct 5 ms 376 KB Output is correct
34 Correct 6 ms 376 KB Output is correct
35 Correct 5 ms 376 KB Output is correct
36 Correct 6 ms 376 KB Output is correct
37 Correct 6 ms 376 KB Output is correct
38 Correct 189 ms 3088 KB Output is correct
39 Correct 128 ms 3060 KB Output is correct
40 Correct 103 ms 3056 KB Output is correct
41 Correct 185 ms 3100 KB Output is correct
42 Correct 102 ms 3060 KB Output is correct
43 Correct 117 ms 3060 KB Output is correct
44 Correct 152 ms 3036 KB Output is correct
45 Correct 277 ms 3024 KB Output is correct
46 Correct 147 ms 3060 KB Output is correct
47 Correct 266 ms 2932 KB Output is correct
48 Correct 142 ms 2932 KB Output is correct
49 Correct 135 ms 2804 KB Output is correct
50 Correct 106 ms 2804 KB Output is correct
51 Correct 117 ms 3188 KB Output is correct
52 Correct 124 ms 3060 KB Output is correct
53 Correct 122 ms 3188 KB Output is correct
54 Correct 84 ms 3060 KB Output is correct
55 Correct 186 ms 3060 KB Output is correct
56 Correct 66 ms 2168 KB Output is correct
57 Correct 33 ms 1784 KB Output is correct
58 Correct 51 ms 2172 KB Output is correct
59 Correct 126 ms 2168 KB Output is correct
60 Correct 39 ms 1784 KB Output is correct
61 Correct 81 ms 2548 KB Output is correct
62 Correct 240 ms 3060 KB Output is correct
63 Correct 241 ms 3060 KB Output is correct
64 Correct 255 ms 3056 KB Output is correct
65 Correct 250 ms 3060 KB Output is correct
66 Correct 241 ms 3108 KB Output is correct
67 Correct 251 ms 3060 KB Output is correct
68 Correct 238 ms 3080 KB Output is correct
69 Correct 251 ms 3060 KB Output is correct
70 Correct 241 ms 3056 KB Output is correct
71 Correct 232 ms 3060 KB Output is correct
72 Correct 191 ms 3056 KB Output is correct
73 Correct 158 ms 3060 KB Output is correct