#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define db double
#define ll __int128
#define int long long
#define pb push_back
#define fs first
#define sd second
#define Mod long(1e9 + 7)
#define all(x) x.begin(), x.end()
#define unvisited long(-1)
#define Eps double(1e-9)
#define _for(i, n) for(int i = 0; i < (n); i++)
#define dbg(x) cout << #x ": " << x << endl;
const int Max = 1e6 + 7, Inf = 1e15 + 7;
void print(bool x) { cout << (x ? "YES" : "NO") << endl; }
string tostring (__int128 x)
{
string ans = "";
while(x > 0)
{
ans += (x % 10 + '0');
x /= 10;
}
reverse(all(ans));
return ans;
}
void solve()
{
int n, m, ans = 0; cin >> n >> m;
vector <pair<int, int>> v(n);
vector <int> c(m);
for(auto& u : v) cin >> u.fs >> u.sd;
for(auto& u : c) cin >> u;
sort(all(v)); sort(all(c)); reverse(all(c));
priority_queue <pair<int, int>> pq;
for(int i = 0; i < n; i++)
pq.push({ v[i].sd, i });
for(int i = 0; i < m; i++)
{
while(!pq.empty())
{
if(v[pq.top().sd].fs > c[i])
pq.pop();
else
break;
}
if(pq.empty()) break;
ans++; pq.pop();
}
cout << ans << endl;
}
int32_t main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
int Q = 1; //cin >> Q;
while (Q--)
{
solve();
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 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 |
600 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 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 |
600 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 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 |
512 KB |
Output is correct |
23 |
Correct |
1 ms |
348 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 |
344 KB |
Output is correct |
29 |
Correct |
1 ms |
348 KB |
Output is correct |
30 |
Correct |
1 ms |
344 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 |
1 ms |
348 KB |
Output is correct |
36 |
Correct |
1 ms |
472 KB |
Output is correct |
37 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 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 |
600 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 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 |
512 KB |
Output is correct |
23 |
Correct |
1 ms |
348 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 |
344 KB |
Output is correct |
29 |
Correct |
1 ms |
348 KB |
Output is correct |
30 |
Correct |
1 ms |
344 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 |
1 ms |
348 KB |
Output is correct |
36 |
Correct |
1 ms |
472 KB |
Output is correct |
37 |
Correct |
1 ms |
348 KB |
Output is correct |
38 |
Correct |
49 ms |
7664 KB |
Output is correct |
39 |
Correct |
44 ms |
7628 KB |
Output is correct |
40 |
Correct |
47 ms |
8396 KB |
Output is correct |
41 |
Correct |
51 ms |
7888 KB |
Output is correct |
42 |
Correct |
45 ms |
7888 KB |
Output is correct |
43 |
Correct |
45 ms |
7888 KB |
Output is correct |
44 |
Correct |
46 ms |
7872 KB |
Output is correct |
45 |
Correct |
51 ms |
7768 KB |
Output is correct |
46 |
Correct |
47 ms |
7652 KB |
Output is correct |
47 |
Correct |
48 ms |
7124 KB |
Output is correct |
48 |
Correct |
44 ms |
7128 KB |
Output is correct |
49 |
Correct |
39 ms |
6676 KB |
Output is correct |
50 |
Correct |
38 ms |
6608 KB |
Output is correct |
51 |
Correct |
52 ms |
7732 KB |
Output is correct |
52 |
Correct |
50 ms |
7888 KB |
Output is correct |
53 |
Correct |
59 ms |
8036 KB |
Output is correct |
54 |
Correct |
41 ms |
7888 KB |
Output is correct |
55 |
Correct |
46 ms |
7884 KB |
Output is correct |
56 |
Correct |
26 ms |
6092 KB |
Output is correct |
57 |
Correct |
14 ms |
2140 KB |
Output is correct |
58 |
Correct |
26 ms |
6132 KB |
Output is correct |
59 |
Correct |
28 ms |
6104 KB |
Output is correct |
60 |
Correct |
15 ms |
2008 KB |
Output is correct |
61 |
Correct |
27 ms |
4564 KB |
Output is correct |
62 |
Correct |
51 ms |
7868 KB |
Output is correct |
63 |
Correct |
50 ms |
7884 KB |
Output is correct |
64 |
Correct |
50 ms |
7888 KB |
Output is correct |
65 |
Correct |
53 ms |
7884 KB |
Output is correct |
66 |
Correct |
51 ms |
7872 KB |
Output is correct |
67 |
Correct |
51 ms |
7872 KB |
Output is correct |
68 |
Correct |
52 ms |
7784 KB |
Output is correct |
69 |
Correct |
52 ms |
7660 KB |
Output is correct |
70 |
Correct |
50 ms |
7632 KB |
Output is correct |
71 |
Correct |
53 ms |
7884 KB |
Output is correct |
72 |
Correct |
51 ms |
8040 KB |
Output is correct |
73 |
Correct |
52 ms |
7768 KB |
Output is correct |