#ifdef LOCAL
#include "local.h"
#else
#include <bits/stdc++.h>
#define debug(...)
#define DB(...)
#endif
using namespace std;
const bool __initialization = []() {
cin.tie(nullptr)->sync_with_stdio(false);
#define TASK "empty"
if (fopen(TASK".inp", "r")) {
(void)(!freopen(TASK".inp", "r", stdin));
(void)(!freopen(TASK".out", "w", stdout)); }
cout << setprecision(12) << fixed;
return true;
}();
using ll = long long;
using ld = long double;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define For(i, l, r) for (int i = (l); i <= (r); ++i)
#define Ford(i, r, l) for (int i = (r); i >= (l); --i)
#define Rep(i, n) For (i, 0, (n) - 1)
#define Repd(i, n) Ford (i, (n) - 1, 0)
#define Fe(...) for (auto __VA_ARGS__)
template <class C> inline int isz(const C& c) { return static_cast<int>(c.size()); }
template <class T> inline bool chmin(T& a, const T& b) { return (a > b) ? a = b, true : false; }
template <class T> inline bool chmax(T& a, const T& b) { return (a < b) ? a = b, true : false; }
constexpr ld eps = 1e-9;
constexpr int inf = 1e9;
constexpr ll linf = 1e18;
// =============================================================================
constexpr int maxn = 1e5 + 5;
struct Pic {
int size, val;
bool operator<(const Pic& o) const {
if (val != o.val) return val < o.val;
return size < o.size;
}
};
int n, nf;
Pic a[maxn];
int frame[maxn];
signed main() {
cin >> n >> nf;
For (i, 1, n) cin >> a[i].size >> a[i].val;
For (i, 1, nf) cin >> frame[i];
sort(a + 1, a + n + 1);
sort(frame + 1, frame + nf + 1);
int ans = 0;
int j = nf;
Ford (i, n, 1) {
if (ans == nf) break;
if (a[i].size <= frame[j]) {
++ans;
--j;
}
}
cout << ans << '\n';
}
// not quite there for subtask 2...
// not even sure if this dp method is correct...
// and the answer is no.
// let's hope something would change after this fix
// there is only one way to know...
// fuck off...
// I mean the idea is flawed in the beginning
// this probably will not help
// goddamn it
// it was close, but not quite close
// the dp formula was off
// man how did they pull that greedy off?
// wonderful
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
0 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 |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
0 ms |
204 KB |
Output is correct |
11 |
Correct |
0 ms |
204 KB |
Output is correct |
12 |
Correct |
0 ms |
204 KB |
Output is correct |
13 |
Correct |
0 ms |
204 KB |
Output is correct |
14 |
Correct |
0 ms |
204 KB |
Output is correct |
15 |
Correct |
0 ms |
204 KB |
Output is correct |
16 |
Correct |
0 ms |
204 KB |
Output is correct |
17 |
Correct |
0 ms |
204 KB |
Output is correct |
18 |
Correct |
0 ms |
204 KB |
Output is correct |
19 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
0 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 |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
0 ms |
204 KB |
Output is correct |
11 |
Correct |
0 ms |
204 KB |
Output is correct |
12 |
Correct |
0 ms |
204 KB |
Output is correct |
13 |
Correct |
0 ms |
204 KB |
Output is correct |
14 |
Correct |
0 ms |
204 KB |
Output is correct |
15 |
Correct |
0 ms |
204 KB |
Output is correct |
16 |
Correct |
0 ms |
204 KB |
Output is correct |
17 |
Correct |
0 ms |
204 KB |
Output is correct |
18 |
Correct |
0 ms |
204 KB |
Output is correct |
19 |
Correct |
1 ms |
204 KB |
Output is correct |
20 |
Correct |
1 ms |
332 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 |
1 ms |
332 KB |
Output is correct |
25 |
Correct |
1 ms |
332 KB |
Output is correct |
26 |
Correct |
1 ms |
332 KB |
Output is correct |
27 |
Correct |
1 ms |
332 KB |
Output is correct |
28 |
Correct |
1 ms |
332 KB |
Output is correct |
29 |
Correct |
1 ms |
332 KB |
Output is correct |
30 |
Correct |
1 ms |
216 KB |
Output is correct |
31 |
Correct |
1 ms |
332 KB |
Output is correct |
32 |
Correct |
1 ms |
332 KB |
Output is correct |
33 |
Correct |
0 ms |
332 KB |
Output is correct |
34 |
Correct |
1 ms |
332 KB |
Output is correct |
35 |
Correct |
0 ms |
204 KB |
Output is correct |
36 |
Correct |
1 ms |
332 KB |
Output is correct |
37 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
0 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 |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
0 ms |
204 KB |
Output is correct |
11 |
Correct |
0 ms |
204 KB |
Output is correct |
12 |
Correct |
0 ms |
204 KB |
Output is correct |
13 |
Correct |
0 ms |
204 KB |
Output is correct |
14 |
Correct |
0 ms |
204 KB |
Output is correct |
15 |
Correct |
0 ms |
204 KB |
Output is correct |
16 |
Correct |
0 ms |
204 KB |
Output is correct |
17 |
Correct |
0 ms |
204 KB |
Output is correct |
18 |
Correct |
0 ms |
204 KB |
Output is correct |
19 |
Correct |
1 ms |
204 KB |
Output is correct |
20 |
Correct |
1 ms |
332 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 |
1 ms |
332 KB |
Output is correct |
25 |
Correct |
1 ms |
332 KB |
Output is correct |
26 |
Correct |
1 ms |
332 KB |
Output is correct |
27 |
Correct |
1 ms |
332 KB |
Output is correct |
28 |
Correct |
1 ms |
332 KB |
Output is correct |
29 |
Correct |
1 ms |
332 KB |
Output is correct |
30 |
Correct |
1 ms |
216 KB |
Output is correct |
31 |
Correct |
1 ms |
332 KB |
Output is correct |
32 |
Correct |
1 ms |
332 KB |
Output is correct |
33 |
Correct |
0 ms |
332 KB |
Output is correct |
34 |
Correct |
1 ms |
332 KB |
Output is correct |
35 |
Correct |
0 ms |
204 KB |
Output is correct |
36 |
Correct |
1 ms |
332 KB |
Output is correct |
37 |
Correct |
1 ms |
332 KB |
Output is correct |
38 |
Correct |
45 ms |
4256 KB |
Output is correct |
39 |
Correct |
39 ms |
4356 KB |
Output is correct |
40 |
Correct |
36 ms |
4320 KB |
Output is correct |
41 |
Correct |
41 ms |
4364 KB |
Output is correct |
42 |
Correct |
41 ms |
4364 KB |
Output is correct |
43 |
Correct |
41 ms |
4256 KB |
Output is correct |
44 |
Correct |
40 ms |
4336 KB |
Output is correct |
45 |
Correct |
41 ms |
4284 KB |
Output is correct |
46 |
Correct |
39 ms |
4212 KB |
Output is correct |
47 |
Correct |
38 ms |
3884 KB |
Output is correct |
48 |
Correct |
36 ms |
3944 KB |
Output is correct |
49 |
Correct |
34 ms |
3524 KB |
Output is correct |
50 |
Correct |
34 ms |
3508 KB |
Output is correct |
51 |
Correct |
43 ms |
4340 KB |
Output is correct |
52 |
Correct |
42 ms |
4492 KB |
Output is correct |
53 |
Correct |
41 ms |
4280 KB |
Output is correct |
54 |
Correct |
35 ms |
4272 KB |
Output is correct |
55 |
Correct |
42 ms |
4276 KB |
Output is correct |
56 |
Correct |
25 ms |
2940 KB |
Output is correct |
57 |
Correct |
16 ms |
1624 KB |
Output is correct |
58 |
Correct |
25 ms |
3008 KB |
Output is correct |
59 |
Correct |
27 ms |
2996 KB |
Output is correct |
60 |
Correct |
16 ms |
1612 KB |
Output is correct |
61 |
Correct |
25 ms |
2592 KB |
Output is correct |
62 |
Correct |
45 ms |
4444 KB |
Output is correct |
63 |
Correct |
44 ms |
4316 KB |
Output is correct |
64 |
Correct |
42 ms |
4300 KB |
Output is correct |
65 |
Correct |
42 ms |
4356 KB |
Output is correct |
66 |
Correct |
41 ms |
4292 KB |
Output is correct |
67 |
Correct |
42 ms |
4292 KB |
Output is correct |
68 |
Correct |
41 ms |
4296 KB |
Output is correct |
69 |
Correct |
43 ms |
4368 KB |
Output is correct |
70 |
Correct |
43 ms |
4300 KB |
Output is correct |
71 |
Correct |
40 ms |
4352 KB |
Output is correct |
72 |
Correct |
46 ms |
4420 KB |
Output is correct |
73 |
Correct |
40 ms |
4332 KB |
Output is correct |