//DavitMarg
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <bitset>
#include <stack>
#include <cassert>
#include <iterator>
#include <random>
#include <chrono>
#define mod 1000000007ll
#define LL long long
#define LD long double
#define MP make_pair
#define PB push_back
#define all(v) v.begin(), v.end()
#define fastIO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
const int N = 500005;
int n, m;
int c[N];
pair<int, int> a[N];
void solve()
{
cin >> n >> m;
for (int i = 1; i <= n; i++)
cin >> a[i].first >> a[i].second;
for (int i = 1; i <= m; i++)
cin >> c[i];
sort(a + 1, a + 1 + n, [](pair<int, int> a, pair<int, int> b) {
if (a.second == b.second)
return a.first < b.first;
return a.second < b.second;
});
sort(c + 1, c + 1 + m);
int ans = 0;
int p = n;
for (int i = m; i >= 1; i--)
{
while (p >= 1 && a[p].first > c[i])
p--;
if (p >= 1 && a[p].first <= c[i])
{
ans++;
p--;
}
}
cout << ans << endl;
}
int main()
{
fastIO
int T = 1;
//cin >> T;
while (T--)
{
solve();
}
return 0;
}
/*
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2384 KB |
Output is correct |
2 |
Correct |
1 ms |
2384 KB |
Output is correct |
3 |
Correct |
1 ms |
2384 KB |
Output is correct |
4 |
Correct |
1 ms |
2384 KB |
Output is correct |
5 |
Correct |
1 ms |
2384 KB |
Output is correct |
6 |
Correct |
1 ms |
2384 KB |
Output is correct |
7 |
Correct |
1 ms |
2384 KB |
Output is correct |
8 |
Correct |
1 ms |
2384 KB |
Output is correct |
9 |
Correct |
1 ms |
2384 KB |
Output is correct |
10 |
Correct |
1 ms |
2384 KB |
Output is correct |
11 |
Correct |
1 ms |
2384 KB |
Output is correct |
12 |
Correct |
1 ms |
2640 KB |
Output is correct |
13 |
Correct |
1 ms |
2384 KB |
Output is correct |
14 |
Correct |
1 ms |
2384 KB |
Output is correct |
15 |
Correct |
1 ms |
2384 KB |
Output is correct |
16 |
Correct |
1 ms |
2560 KB |
Output is correct |
17 |
Correct |
1 ms |
2384 KB |
Output is correct |
18 |
Correct |
1 ms |
2552 KB |
Output is correct |
19 |
Correct |
1 ms |
2384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2384 KB |
Output is correct |
2 |
Correct |
1 ms |
2384 KB |
Output is correct |
3 |
Correct |
1 ms |
2384 KB |
Output is correct |
4 |
Correct |
1 ms |
2384 KB |
Output is correct |
5 |
Correct |
1 ms |
2384 KB |
Output is correct |
6 |
Correct |
1 ms |
2384 KB |
Output is correct |
7 |
Correct |
1 ms |
2384 KB |
Output is correct |
8 |
Correct |
1 ms |
2384 KB |
Output is correct |
9 |
Correct |
1 ms |
2384 KB |
Output is correct |
10 |
Correct |
1 ms |
2384 KB |
Output is correct |
11 |
Correct |
1 ms |
2384 KB |
Output is correct |
12 |
Correct |
1 ms |
2640 KB |
Output is correct |
13 |
Correct |
1 ms |
2384 KB |
Output is correct |
14 |
Correct |
1 ms |
2384 KB |
Output is correct |
15 |
Correct |
1 ms |
2384 KB |
Output is correct |
16 |
Correct |
1 ms |
2560 KB |
Output is correct |
17 |
Correct |
1 ms |
2384 KB |
Output is correct |
18 |
Correct |
1 ms |
2552 KB |
Output is correct |
19 |
Correct |
1 ms |
2384 KB |
Output is correct |
20 |
Correct |
1 ms |
2384 KB |
Output is correct |
21 |
Correct |
2 ms |
2552 KB |
Output is correct |
22 |
Correct |
1 ms |
2384 KB |
Output is correct |
23 |
Correct |
2 ms |
2384 KB |
Output is correct |
24 |
Correct |
2 ms |
2384 KB |
Output is correct |
25 |
Correct |
1 ms |
2384 KB |
Output is correct |
26 |
Correct |
2 ms |
2552 KB |
Output is correct |
27 |
Correct |
1 ms |
2528 KB |
Output is correct |
28 |
Correct |
2 ms |
2384 KB |
Output is correct |
29 |
Correct |
1 ms |
2384 KB |
Output is correct |
30 |
Correct |
1 ms |
2384 KB |
Output is correct |
31 |
Correct |
1 ms |
2384 KB |
Output is correct |
32 |
Correct |
2 ms |
2384 KB |
Output is correct |
33 |
Correct |
1 ms |
2384 KB |
Output is correct |
34 |
Correct |
2 ms |
2384 KB |
Output is correct |
35 |
Correct |
1 ms |
2384 KB |
Output is correct |
36 |
Correct |
2 ms |
2384 KB |
Output is correct |
37 |
Correct |
1 ms |
2384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2384 KB |
Output is correct |
2 |
Correct |
1 ms |
2384 KB |
Output is correct |
3 |
Correct |
1 ms |
2384 KB |
Output is correct |
4 |
Correct |
1 ms |
2384 KB |
Output is correct |
5 |
Correct |
1 ms |
2384 KB |
Output is correct |
6 |
Correct |
1 ms |
2384 KB |
Output is correct |
7 |
Correct |
1 ms |
2384 KB |
Output is correct |
8 |
Correct |
1 ms |
2384 KB |
Output is correct |
9 |
Correct |
1 ms |
2384 KB |
Output is correct |
10 |
Correct |
1 ms |
2384 KB |
Output is correct |
11 |
Correct |
1 ms |
2384 KB |
Output is correct |
12 |
Correct |
1 ms |
2640 KB |
Output is correct |
13 |
Correct |
1 ms |
2384 KB |
Output is correct |
14 |
Correct |
1 ms |
2384 KB |
Output is correct |
15 |
Correct |
1 ms |
2384 KB |
Output is correct |
16 |
Correct |
1 ms |
2560 KB |
Output is correct |
17 |
Correct |
1 ms |
2384 KB |
Output is correct |
18 |
Correct |
1 ms |
2552 KB |
Output is correct |
19 |
Correct |
1 ms |
2384 KB |
Output is correct |
20 |
Correct |
1 ms |
2384 KB |
Output is correct |
21 |
Correct |
2 ms |
2552 KB |
Output is correct |
22 |
Correct |
1 ms |
2384 KB |
Output is correct |
23 |
Correct |
2 ms |
2384 KB |
Output is correct |
24 |
Correct |
2 ms |
2384 KB |
Output is correct |
25 |
Correct |
1 ms |
2384 KB |
Output is correct |
26 |
Correct |
2 ms |
2552 KB |
Output is correct |
27 |
Correct |
1 ms |
2528 KB |
Output is correct |
28 |
Correct |
2 ms |
2384 KB |
Output is correct |
29 |
Correct |
1 ms |
2384 KB |
Output is correct |
30 |
Correct |
1 ms |
2384 KB |
Output is correct |
31 |
Correct |
1 ms |
2384 KB |
Output is correct |
32 |
Correct |
2 ms |
2384 KB |
Output is correct |
33 |
Correct |
1 ms |
2384 KB |
Output is correct |
34 |
Correct |
2 ms |
2384 KB |
Output is correct |
35 |
Correct |
1 ms |
2384 KB |
Output is correct |
36 |
Correct |
2 ms |
2384 KB |
Output is correct |
37 |
Correct |
1 ms |
2384 KB |
Output is correct |
38 |
Correct |
43 ms |
7756 KB |
Output is correct |
39 |
Correct |
37 ms |
7496 KB |
Output is correct |
40 |
Correct |
32 ms |
7504 KB |
Output is correct |
41 |
Correct |
34 ms |
7548 KB |
Output is correct |
42 |
Correct |
35 ms |
7664 KB |
Output is correct |
43 |
Correct |
38 ms |
7536 KB |
Output is correct |
44 |
Correct |
37 ms |
7412 KB |
Output is correct |
45 |
Correct |
37 ms |
7496 KB |
Output is correct |
46 |
Correct |
35 ms |
7496 KB |
Output is correct |
47 |
Correct |
33 ms |
7240 KB |
Output is correct |
48 |
Correct |
32 ms |
7260 KB |
Output is correct |
49 |
Correct |
31 ms |
7056 KB |
Output is correct |
50 |
Correct |
29 ms |
6992 KB |
Output is correct |
51 |
Correct |
37 ms |
7672 KB |
Output is correct |
52 |
Correct |
43 ms |
7496 KB |
Output is correct |
53 |
Correct |
35 ms |
7504 KB |
Output is correct |
54 |
Correct |
42 ms |
7684 KB |
Output is correct |
55 |
Correct |
37 ms |
7504 KB |
Output is correct |
56 |
Correct |
23 ms |
6480 KB |
Output is correct |
57 |
Correct |
14 ms |
3516 KB |
Output is correct |
58 |
Correct |
23 ms |
6480 KB |
Output is correct |
59 |
Correct |
23 ms |
6488 KB |
Output is correct |
60 |
Correct |
15 ms |
3420 KB |
Output is correct |
61 |
Correct |
23 ms |
6224 KB |
Output is correct |
62 |
Correct |
36 ms |
7504 KB |
Output is correct |
63 |
Correct |
36 ms |
7504 KB |
Output is correct |
64 |
Correct |
36 ms |
7496 KB |
Output is correct |
65 |
Correct |
38 ms |
7504 KB |
Output is correct |
66 |
Correct |
34 ms |
7504 KB |
Output is correct |
67 |
Correct |
36 ms |
7496 KB |
Output is correct |
68 |
Correct |
38 ms |
7516 KB |
Output is correct |
69 |
Correct |
37 ms |
7560 KB |
Output is correct |
70 |
Correct |
35 ms |
7504 KB |
Output is correct |
71 |
Correct |
39 ms |
7496 KB |
Output is correct |
72 |
Correct |
37 ms |
7576 KB |
Output is correct |
73 |
Correct |
34 ms |
7680 KB |
Output is correct |