#include <bits/stdc++.h>
using namespace std;
const int N=1e5+3;
int nr[N],M[N];
pair<int,int>T[N];
int n,m;
int bs(int x,int dl)
{
int pocz=0,kon=dl+1;
while(pocz+1<kon)
{
int mid=(pocz+kon)/2;
if(nr[mid]>x)kon=mid;
else pocz=mid;
}
return kon;
}
bool f(int x)
{
for(int i=1;i<=n;i++)nr[i]=1e9;
int maks=0;
for(int i=1;i<=n;i++)
{
int a=T[i].second,ind=bs(a,maks);
if(a<=M[ind+x])
{
nr[ind]=min(a,nr[ind]);
maks=max(maks,ind);
}
if(maks+x==m)return true;
}
return false;
}
int main()
{
cin>>n>>m;
for(int i=1;i<=n;i++)
{
cin>>T[i].second>>T[i].first;
}
sort(T+1,T+n+1);
for(int i=1;i<=m;i++)cin>>M[i];
sort(M+1,M+m+1);
int pocz=0,kon=min(m,n)+1;
while(pocz+1<kon)
{
int mid=(pocz+kon)/2;
if(f(m-mid))pocz=mid;
else kon=mid;
}
cout<<pocz;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
308 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
308 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
308 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |