#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pb push_back
#define debug(x) cerr<<#x<<"="<<x<<endl
#define pq priority_queue
#define inf 1ll<<60
#define rep(i,a,b) for (ll i=a;i<(b);i++)
#define MP make_pair
#define SZ(x) (int(x.size()))
#define mod 1000000007
#define ALL(x) x.begin(),x.end()
#define endl "\n"
void inc(ll &a,ll b) {a=(a+b)%mod;}
void dec(ll &a,ll b) {a=(a-b+mod)%mod;}
int prod(ll a,ll b) {return ll(a)*ll(b)%mod;}
int lowbit(ll x) {return x&(-x);}
ll p0w(ll base,ll p) {ll ret=1;while(p>0){if (p%2ll==1ll) ret=ret*base%mod;base=base*base%mod;p/=2ll;}return ret;}
bool cmp(pll a,pll b){
if(a.se==b.se)return a.fi>b.fi;
return a.se>b.se;
}
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
ll n,m;cin>>n>>m;
vector<pll>alist;
vector<ll>blist;
rep(i,0,n){
ll a,b;cin>>a>>b;
alist.pb(MP(a,b));
}
sort(ALL(alist),cmp);
rep(i,0,m){
ll x;cin>>x;
blist.pb(x);
}
sort(ALL(blist),greater<ll>());
ll p=0,pp=0,ans=0;
while(p<n and pp<m){
if(alist[p].fi<=blist[pp]){
pp++;
ans++;
}
p++;
}
cout<<ans<<endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
344 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 |
0 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 |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
456 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
600 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
456 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
344 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 |
0 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 |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
456 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
600 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
456 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 |
344 KB |
Output is correct |
22 |
Correct |
1 ms |
348 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 |
604 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 |
344 KB |
Output is correct |
33 |
Correct |
1 ms |
344 KB |
Output is correct |
34 |
Correct |
1 ms |
616 KB |
Output is correct |
35 |
Correct |
1 ms |
360 KB |
Output is correct |
36 |
Correct |
1 ms |
360 KB |
Output is correct |
37 |
Correct |
1 ms |
388 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
344 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 |
0 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 |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
456 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
600 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
456 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 |
344 KB |
Output is correct |
22 |
Correct |
1 ms |
348 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 |
604 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 |
344 KB |
Output is correct |
33 |
Correct |
1 ms |
344 KB |
Output is correct |
34 |
Correct |
1 ms |
616 KB |
Output is correct |
35 |
Correct |
1 ms |
360 KB |
Output is correct |
36 |
Correct |
1 ms |
360 KB |
Output is correct |
37 |
Correct |
1 ms |
388 KB |
Output is correct |
38 |
Correct |
39 ms |
6612 KB |
Output is correct |
39 |
Correct |
38 ms |
6600 KB |
Output is correct |
40 |
Correct |
38 ms |
6616 KB |
Output is correct |
41 |
Correct |
40 ms |
6600 KB |
Output is correct |
42 |
Correct |
40 ms |
6596 KB |
Output is correct |
43 |
Correct |
41 ms |
6600 KB |
Output is correct |
44 |
Correct |
41 ms |
6596 KB |
Output is correct |
45 |
Correct |
40 ms |
6600 KB |
Output is correct |
46 |
Correct |
38 ms |
6608 KB |
Output is correct |
47 |
Correct |
35 ms |
6056 KB |
Output is correct |
48 |
Correct |
35 ms |
6084 KB |
Output is correct |
49 |
Correct |
32 ms |
5588 KB |
Output is correct |
50 |
Correct |
33 ms |
5576 KB |
Output is correct |
51 |
Correct |
40 ms |
6616 KB |
Output is correct |
52 |
Correct |
40 ms |
6600 KB |
Output is correct |
53 |
Correct |
39 ms |
6604 KB |
Output is correct |
54 |
Correct |
35 ms |
6720 KB |
Output is correct |
55 |
Correct |
40 ms |
6560 KB |
Output is correct |
56 |
Correct |
25 ms |
4056 KB |
Output is correct |
57 |
Correct |
15 ms |
2300 KB |
Output is correct |
58 |
Correct |
25 ms |
4052 KB |
Output is correct |
59 |
Correct |
25 ms |
4064 KB |
Output is correct |
60 |
Correct |
15 ms |
2264 KB |
Output is correct |
61 |
Correct |
24 ms |
4056 KB |
Output is correct |
62 |
Correct |
42 ms |
6604 KB |
Output is correct |
63 |
Correct |
39 ms |
6596 KB |
Output is correct |
64 |
Correct |
50 ms |
6728 KB |
Output is correct |
65 |
Correct |
44 ms |
6596 KB |
Output is correct |
66 |
Correct |
39 ms |
6736 KB |
Output is correct |
67 |
Correct |
49 ms |
6600 KB |
Output is correct |
68 |
Correct |
39 ms |
6600 KB |
Output is correct |
69 |
Correct |
41 ms |
6596 KB |
Output is correct |
70 |
Correct |
42 ms |
6644 KB |
Output is correct |
71 |
Correct |
39 ms |
6596 KB |
Output is correct |
72 |
Correct |
40 ms |
6596 KB |
Output is correct |
73 |
Correct |
38 ms |
6604 KB |
Output is correct |