/**
* author : Lăng Trọng Đạt
* created: 2024-08-25
**/
#include <bits/stdc++.h>
using namespace std;
#ifndef LANG_DAT
#define db(...) ;
#endif // LANG_DAT
#define int long long
#define mp make_pair
#define f first
#define se second
#define pb push_back
#define all(v) (v).begin(), (v).end()
using pii = pair<int, int>;
using vi = vector<int>;
#define FOR(i, a, b) for (int i = a; (i) <= (b); i++)
void mx(int& a, int b) { if (b > a) a = b; }
void mi(int& a, int b) { if (b < a) a = b; }
#define si(x) (int)(x.size())
const int INF = 1e18;
const int MOD = 1e9 + 7;
const int N = 1e5 + 5;
int w[N];
int n, m, k, a, b;
vector<pii> pic;
int32_t main() {
cin.tie(0)->sync_with_stdio(0);
if (fopen("hi.inp", "r")) {
freopen("hi.inp", "r", stdin);
// freopen("hi.out", "w", stdout);
}
cin >> n >> m;
pic.resize(n);
for (auto&[v, s] : pic) cin >> s >> v;
FOR(i, 1, m) {
cin >> w[i];
}
db(pic)
sort(all(pic), greater<pii>());
sort(w + 1, w + m + 1, greater<int>());
int ans = 0, pos = 0;
FOR(i, 1, m) {
db(pos, pic[pos], w[i])
while (pos < n && pic[pos].se > w[i]) pos++;
if (pos == n) break;
pos++;
ans++;
}
cout << ans;
}
Compilation message
joi2019_ho_t2.cpp: In function 'int32_t main()':
joi2019_ho_t2.cpp:40:15: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
40 | for (auto&[v, s] : pic) cin >> s >> v;
| ^
joi2019_ho_t2.cpp:34:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
34 | freopen("hi.inp", "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
468 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
604 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
468 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
604 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
1 ms |
604 KB |
Output is correct |
24 |
Correct |
1 ms |
348 KB |
Output is correct |
25 |
Correct |
1 ms |
348 KB |
Output is correct |
26 |
Correct |
1 ms |
348 KB |
Output is correct |
27 |
Correct |
1 ms |
348 KB |
Output is correct |
28 |
Correct |
1 ms |
348 KB |
Output is correct |
29 |
Correct |
1 ms |
348 KB |
Output is correct |
30 |
Correct |
1 ms |
348 KB |
Output is correct |
31 |
Correct |
1 ms |
348 KB |
Output is correct |
32 |
Correct |
1 ms |
348 KB |
Output is correct |
33 |
Correct |
1 ms |
348 KB |
Output is correct |
34 |
Correct |
1 ms |
348 KB |
Output is correct |
35 |
Correct |
0 ms |
344 KB |
Output is correct |
36 |
Correct |
1 ms |
348 KB |
Output is correct |
37 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
468 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
604 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
1 ms |
604 KB |
Output is correct |
24 |
Correct |
1 ms |
348 KB |
Output is correct |
25 |
Correct |
1 ms |
348 KB |
Output is correct |
26 |
Correct |
1 ms |
348 KB |
Output is correct |
27 |
Correct |
1 ms |
348 KB |
Output is correct |
28 |
Correct |
1 ms |
348 KB |
Output is correct |
29 |
Correct |
1 ms |
348 KB |
Output is correct |
30 |
Correct |
1 ms |
348 KB |
Output is correct |
31 |
Correct |
1 ms |
348 KB |
Output is correct |
32 |
Correct |
1 ms |
348 KB |
Output is correct |
33 |
Correct |
1 ms |
348 KB |
Output is correct |
34 |
Correct |
1 ms |
348 KB |
Output is correct |
35 |
Correct |
0 ms |
344 KB |
Output is correct |
36 |
Correct |
1 ms |
348 KB |
Output is correct |
37 |
Correct |
1 ms |
348 KB |
Output is correct |
38 |
Correct |
45 ms |
5632 KB |
Output is correct |
39 |
Correct |
34 ms |
5724 KB |
Output is correct |
40 |
Correct |
33 ms |
5572 KB |
Output is correct |
41 |
Correct |
35 ms |
5720 KB |
Output is correct |
42 |
Correct |
39 ms |
5468 KB |
Output is correct |
43 |
Correct |
35 ms |
5456 KB |
Output is correct |
44 |
Correct |
37 ms |
5484 KB |
Output is correct |
45 |
Correct |
36 ms |
5456 KB |
Output is correct |
46 |
Correct |
34 ms |
5468 KB |
Output is correct |
47 |
Correct |
32 ms |
4956 KB |
Output is correct |
48 |
Correct |
30 ms |
5100 KB |
Output is correct |
49 |
Correct |
29 ms |
4472 KB |
Output is correct |
50 |
Correct |
33 ms |
4592 KB |
Output is correct |
51 |
Correct |
35 ms |
5712 KB |
Output is correct |
52 |
Correct |
35 ms |
5504 KB |
Output is correct |
53 |
Correct |
33 ms |
5456 KB |
Output is correct |
54 |
Correct |
28 ms |
5720 KB |
Output is correct |
55 |
Correct |
34 ms |
5724 KB |
Output is correct |
56 |
Correct |
20 ms |
3928 KB |
Output is correct |
57 |
Correct |
17 ms |
2140 KB |
Output is correct |
58 |
Correct |
22 ms |
3748 KB |
Output is correct |
59 |
Correct |
22 ms |
3952 KB |
Output is correct |
60 |
Correct |
13 ms |
2136 KB |
Output is correct |
61 |
Correct |
21 ms |
3420 KB |
Output is correct |
62 |
Correct |
36 ms |
5460 KB |
Output is correct |
63 |
Correct |
33 ms |
5856 KB |
Output is correct |
64 |
Correct |
36 ms |
5464 KB |
Output is correct |
65 |
Correct |
33 ms |
5720 KB |
Output is correct |
66 |
Correct |
36 ms |
5500 KB |
Output is correct |
67 |
Correct |
46 ms |
5460 KB |
Output is correct |
68 |
Correct |
35 ms |
5456 KB |
Output is correct |
69 |
Correct |
37 ms |
5460 KB |
Output is correct |
70 |
Correct |
35 ms |
5720 KB |
Output is correct |
71 |
Correct |
34 ms |
5720 KB |
Output is correct |
72 |
Correct |
49 ms |
5724 KB |
Output is correct |
73 |
Correct |
34 ms |
5724 KB |
Output is correct |