#include <bits/stdc++.h>
#define ii pair<int, int>
#define fi first
#define se second
#define inf 0x3f3f3f3f3f3f3f3f
using namespace std;
using ll = long long;
const ll mod=1e9+7;
const int nx=1e5+5;
int n, m, f[nx], lim[nx], d, c, g, ans;
ii a[nx];
bool cmp(ii a, ii b)
{
return a.se>b.se;
}
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin>>n>>m;
for(int i = 1; i <= n; i++)
cin>>a[i].fi>>a[i].se;
sort(a+1, a+n+1, cmp);
for(int i = 1; i <= m; i++)
cin>>f[i];
sort(f+1, f+m+1, greater<int>());
ans=1;
for(int i = 1; i <= n; i++)
{
d=1;
c=m;
lim[i]=0;
while(d<=c)
{
g=(d+c)>>1;
if(f[g]>=a[i].fi)
{
lim[i]=g;
d=g+1;
}
else c=g-1;
}
if(lim[i]>=ans)
ans++;
}
cout<<ans-1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |