#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long
using namespace std;
struct pict {
ll s;
ll v;
pict(){}
pict(ll s, ll v) : s(s), v(v) {}
};
bool cmp(pict& A, pict& B) {
if (A.v != B.v)
return A.v < B.v;
return A.s < B.s;
}
int n, m;
bool check(vector<pict>& arr, vector<ll>& f, int x) {
int ind = m - x;
int pt = 0;
while (ind < m && pt < n) {
if (arr[pt].s <= f[ind]) {
ind++;
pt++;
continue;
}
pt++;
}
return (ind == m);
}
int main() {
cin >> n >> m;
vector<pict> arr(n);
for (int i = 0; i < n; i++) {
ll s, v;
cin >> s >> v;
arr[i] = { s, v };
}
sort(arr.begin(), arr.end(), cmp);
vector<ll> f(m);
for (int i = 0; i < m; i++)
cin >> f[i];
sort(f.begin(), f.end());
int L = -1;
int R = min(n, m) + 1;
while (R - L > 1) {
int M = (L + R) / 2;
if (check(arr, f, M))
L = M;
else
R = M;
}
cout << L << endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
2 |
Correct |
4 ms |
256 KB |
Output is correct |
3 |
Correct |
4 ms |
256 KB |
Output is correct |
4 |
Correct |
4 ms |
256 KB |
Output is correct |
5 |
Correct |
5 ms |
256 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
4 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
256 KB |
Output is correct |
9 |
Correct |
5 ms |
256 KB |
Output is correct |
10 |
Correct |
4 ms |
384 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
5 ms |
256 KB |
Output is correct |
13 |
Correct |
5 ms |
256 KB |
Output is correct |
14 |
Correct |
5 ms |
256 KB |
Output is correct |
15 |
Correct |
5 ms |
384 KB |
Output is correct |
16 |
Correct |
5 ms |
384 KB |
Output is correct |
17 |
Correct |
4 ms |
384 KB |
Output is correct |
18 |
Correct |
5 ms |
256 KB |
Output is correct |
19 |
Correct |
5 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
2 |
Correct |
4 ms |
256 KB |
Output is correct |
3 |
Correct |
4 ms |
256 KB |
Output is correct |
4 |
Correct |
4 ms |
256 KB |
Output is correct |
5 |
Correct |
5 ms |
256 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
4 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
256 KB |
Output is correct |
9 |
Correct |
5 ms |
256 KB |
Output is correct |
10 |
Correct |
4 ms |
384 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
5 ms |
256 KB |
Output is correct |
13 |
Correct |
5 ms |
256 KB |
Output is correct |
14 |
Correct |
5 ms |
256 KB |
Output is correct |
15 |
Correct |
5 ms |
384 KB |
Output is correct |
16 |
Correct |
5 ms |
384 KB |
Output is correct |
17 |
Correct |
4 ms |
384 KB |
Output is correct |
18 |
Correct |
5 ms |
256 KB |
Output is correct |
19 |
Correct |
5 ms |
384 KB |
Output is correct |
20 |
Correct |
7 ms |
384 KB |
Output is correct |
21 |
Correct |
8 ms |
384 KB |
Output is correct |
22 |
Correct |
7 ms |
384 KB |
Output is correct |
23 |
Correct |
7 ms |
384 KB |
Output is correct |
24 |
Correct |
7 ms |
384 KB |
Output is correct |
25 |
Correct |
7 ms |
384 KB |
Output is correct |
26 |
Correct |
6 ms |
384 KB |
Output is correct |
27 |
Correct |
7 ms |
384 KB |
Output is correct |
28 |
Correct |
7 ms |
384 KB |
Output is correct |
29 |
Correct |
8 ms |
384 KB |
Output is correct |
30 |
Correct |
6 ms |
384 KB |
Output is correct |
31 |
Correct |
8 ms |
384 KB |
Output is correct |
32 |
Correct |
6 ms |
384 KB |
Output is correct |
33 |
Correct |
6 ms |
384 KB |
Output is correct |
34 |
Correct |
6 ms |
384 KB |
Output is correct |
35 |
Correct |
6 ms |
384 KB |
Output is correct |
36 |
Correct |
7 ms |
384 KB |
Output is correct |
37 |
Correct |
7 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
2 |
Correct |
4 ms |
256 KB |
Output is correct |
3 |
Correct |
4 ms |
256 KB |
Output is correct |
4 |
Correct |
4 ms |
256 KB |
Output is correct |
5 |
Correct |
5 ms |
256 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
4 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
256 KB |
Output is correct |
9 |
Correct |
5 ms |
256 KB |
Output is correct |
10 |
Correct |
4 ms |
384 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
5 ms |
256 KB |
Output is correct |
13 |
Correct |
5 ms |
256 KB |
Output is correct |
14 |
Correct |
5 ms |
256 KB |
Output is correct |
15 |
Correct |
5 ms |
384 KB |
Output is correct |
16 |
Correct |
5 ms |
384 KB |
Output is correct |
17 |
Correct |
4 ms |
384 KB |
Output is correct |
18 |
Correct |
5 ms |
256 KB |
Output is correct |
19 |
Correct |
5 ms |
384 KB |
Output is correct |
20 |
Correct |
7 ms |
384 KB |
Output is correct |
21 |
Correct |
8 ms |
384 KB |
Output is correct |
22 |
Correct |
7 ms |
384 KB |
Output is correct |
23 |
Correct |
7 ms |
384 KB |
Output is correct |
24 |
Correct |
7 ms |
384 KB |
Output is correct |
25 |
Correct |
7 ms |
384 KB |
Output is correct |
26 |
Correct |
6 ms |
384 KB |
Output is correct |
27 |
Correct |
7 ms |
384 KB |
Output is correct |
28 |
Correct |
7 ms |
384 KB |
Output is correct |
29 |
Correct |
8 ms |
384 KB |
Output is correct |
30 |
Correct |
6 ms |
384 KB |
Output is correct |
31 |
Correct |
8 ms |
384 KB |
Output is correct |
32 |
Correct |
6 ms |
384 KB |
Output is correct |
33 |
Correct |
6 ms |
384 KB |
Output is correct |
34 |
Correct |
6 ms |
384 KB |
Output is correct |
35 |
Correct |
6 ms |
384 KB |
Output is correct |
36 |
Correct |
7 ms |
384 KB |
Output is correct |
37 |
Correct |
7 ms |
384 KB |
Output is correct |
38 |
Correct |
208 ms |
5632 KB |
Output is correct |
39 |
Correct |
203 ms |
5624 KB |
Output is correct |
40 |
Correct |
232 ms |
5572 KB |
Output is correct |
41 |
Correct |
212 ms |
5568 KB |
Output is correct |
42 |
Correct |
205 ms |
5624 KB |
Output is correct |
43 |
Correct |
213 ms |
5608 KB |
Output is correct |
44 |
Correct |
205 ms |
5624 KB |
Output is correct |
45 |
Correct |
201 ms |
5496 KB |
Output is correct |
46 |
Correct |
200 ms |
5760 KB |
Output is correct |
47 |
Correct |
182 ms |
4984 KB |
Output is correct |
48 |
Correct |
181 ms |
4984 KB |
Output is correct |
49 |
Correct |
162 ms |
4472 KB |
Output is correct |
50 |
Correct |
162 ms |
4472 KB |
Output is correct |
51 |
Correct |
202 ms |
5624 KB |
Output is correct |
52 |
Correct |
206 ms |
5624 KB |
Output is correct |
53 |
Correct |
203 ms |
5496 KB |
Output is correct |
54 |
Correct |
193 ms |
5624 KB |
Output is correct |
55 |
Correct |
202 ms |
5624 KB |
Output is correct |
56 |
Correct |
139 ms |
3780 KB |
Output is correct |
57 |
Correct |
71 ms |
2036 KB |
Output is correct |
58 |
Correct |
133 ms |
3832 KB |
Output is correct |
59 |
Correct |
157 ms |
3832 KB |
Output is correct |
60 |
Correct |
74 ms |
2040 KB |
Output is correct |
61 |
Correct |
117 ms |
3320 KB |
Output is correct |
62 |
Correct |
209 ms |
5624 KB |
Output is correct |
63 |
Correct |
237 ms |
5624 KB |
Output is correct |
64 |
Correct |
210 ms |
5624 KB |
Output is correct |
65 |
Correct |
219 ms |
5624 KB |
Output is correct |
66 |
Correct |
262 ms |
5628 KB |
Output is correct |
67 |
Correct |
208 ms |
5624 KB |
Output is correct |
68 |
Correct |
229 ms |
5624 KB |
Output is correct |
69 |
Correct |
222 ms |
5752 KB |
Output is correct |
70 |
Correct |
208 ms |
5624 KB |
Output is correct |
71 |
Correct |
260 ms |
5624 KB |
Output is correct |
72 |
Correct |
211 ms |
5544 KB |
Output is correct |
73 |
Correct |
213 ms |
5624 KB |
Output is correct |