//reading is hard
#include <bits/stdc++.h>
using namespace std;
template<class T, class U>
void ckmin(T &a, U b)
{
if (a > b) a = b;
}
template<class T, class U>
void ckmax(T &a, U b)
{
if (a < b) a = b;
}
#define MP make_pair
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define FOR(i, a, b) for (auto i = (a); i < (b); i++)
#define FORD(i, a, b) for (auto i = (a) - 1; i >= (b); i--)
#define SZ(x) ((int) ((x).size()))
#define ALL(x) (x).begin(), (x).end()
#define INF 1000000007
#define LLINF 2696969696969696969ll
#define MAXN 100013
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
int N, M;
pii arr[MAXN];
int lim[MAXN];
vi dp;
bool check(int x)
{
//you need smth 0...x - 1
vi nums;
FOR(i, 0, x)
{
nums.PB(lim[M - 1 - i]);
}
reverse(ALL(nums));
// for (int x : nums)
// {
// cerr << x << ' ';
// }
// cerr << endl;
int iter = 0;
FOR(i, 0, x)
{
while(iter < N && arr[iter].se > nums[i]) iter++;
iter++;
}
return (iter <= N);
}
int32_t main()
{
ios_base::sync_with_stdio(0); cin.tie(0);
cin >> N >> M;
FOR(i, 0, N)
{
cin >> arr[i].se >> arr[i].fi;
}
sort(arr, arr + N);
FOR(i, 0, M)
{
cin >> lim[i];
}
sort(lim, lim + M);
int lo = 0, hi = min(N, M);
while(hi > lo)
{
int mid = (hi + lo + 1) >> 1;
if (check(mid)) lo = mid;
else hi = mid - 1;
}
cout << lo << '\n';
}
# |
결과 |
실행 시간 |
메모리 |
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 |
380 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 |
348 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 |
388 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 |
380 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 |
348 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 |
388 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 |
376 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 |
376 KB |
Output is correct |
25 |
Correct |
3 ms |
376 KB |
Output is correct |
26 |
Correct |
3 ms |
376 KB |
Output is correct |
27 |
Correct |
3 ms |
376 KB |
Output is correct |
28 |
Correct |
3 ms |
376 KB |
Output is correct |
29 |
Correct |
2 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 |
2 ms |
376 KB |
Output is correct |
33 |
Correct |
2 ms |
376 KB |
Output is correct |
34 |
Correct |
2 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 |
380 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 |
348 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 |
388 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 |
376 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 |
376 KB |
Output is correct |
25 |
Correct |
3 ms |
376 KB |
Output is correct |
26 |
Correct |
3 ms |
376 KB |
Output is correct |
27 |
Correct |
3 ms |
376 KB |
Output is correct |
28 |
Correct |
3 ms |
376 KB |
Output is correct |
29 |
Correct |
2 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 |
2 ms |
376 KB |
Output is correct |
33 |
Correct |
2 ms |
376 KB |
Output is correct |
34 |
Correct |
2 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 |
74 ms |
5364 KB |
Output is correct |
39 |
Correct |
71 ms |
5348 KB |
Output is correct |
40 |
Correct |
68 ms |
5388 KB |
Output is correct |
41 |
Correct |
75 ms |
5360 KB |
Output is correct |
42 |
Correct |
63 ms |
4728 KB |
Output is correct |
43 |
Correct |
63 ms |
4844 KB |
Output is correct |
44 |
Correct |
66 ms |
5164 KB |
Output is correct |
45 |
Correct |
74 ms |
5332 KB |
Output is correct |
46 |
Correct |
73 ms |
5328 KB |
Output is correct |
47 |
Correct |
68 ms |
4812 KB |
Output is correct |
48 |
Correct |
65 ms |
4828 KB |
Output is correct |
49 |
Correct |
61 ms |
4412 KB |
Output is correct |
50 |
Correct |
60 ms |
4424 KB |
Output is correct |
51 |
Correct |
64 ms |
4860 KB |
Output is correct |
52 |
Correct |
63 ms |
4828 KB |
Output is correct |
53 |
Correct |
64 ms |
4776 KB |
Output is correct |
54 |
Correct |
67 ms |
5388 KB |
Output is correct |
55 |
Correct |
80 ms |
5416 KB |
Output is correct |
56 |
Correct |
42 ms |
3064 KB |
Output is correct |
57 |
Correct |
24 ms |
1784 KB |
Output is correct |
58 |
Correct |
44 ms |
3192 KB |
Output is correct |
59 |
Correct |
39 ms |
3192 KB |
Output is correct |
60 |
Correct |
24 ms |
1656 KB |
Output is correct |
61 |
Correct |
42 ms |
2940 KB |
Output is correct |
62 |
Correct |
77 ms |
5236 KB |
Output is correct |
63 |
Correct |
73 ms |
5220 KB |
Output is correct |
64 |
Correct |
75 ms |
5212 KB |
Output is correct |
65 |
Correct |
74 ms |
5288 KB |
Output is correct |
66 |
Correct |
73 ms |
5236 KB |
Output is correct |
67 |
Correct |
74 ms |
5236 KB |
Output is correct |
68 |
Correct |
73 ms |
5220 KB |
Output is correct |
69 |
Correct |
75 ms |
5220 KB |
Output is correct |
70 |
Correct |
71 ms |
5204 KB |
Output is correct |
71 |
Correct |
73 ms |
5240 KB |
Output is correct |
72 |
Correct |
69 ms |
5204 KB |
Output is correct |
73 |
Correct |
71 ms |
5260 KB |
Output is correct |