이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |