이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define N 1000005
#define ll long long int
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define sp " "
#define endl "\n"
#define fi first
#define se second
#define ii pair<int,int>
#define lli pair<ll,ll>
#define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
#define fast2 freopen ("myfile.in","r",stdin);freopen ("myfile.out","w",stdout);
#define mod 1000000007
#define fs(x,y) for(int i=1;i<=y;i++) cin>>x[i];
#define fo(i,x,y) for(int i=x;i<=y;i++)
using namespace std;
ll n,ar[N],sum,m;
lli p[N];
bool check(int x)
{
if(x==0)
return 1;
int q=m;
for(int i=n;i>=1 && q>m-x;i--)
{
if(p[i].se<=ar[q])
q--;
// cout<<q<<sp<<p[i].se<<sp<<ar[q]<<endl;
}
// cout<<q<<sp;
if(q==m-x)
return true;
return false;
}
int main()
{
fast;
cin>>n>>m;
fo(i,1,n)
cin>>p[i].se>>p[i].fi;
sort(p+1,p+n+1);
fs(ar,m)
// cout<<endl;
sort(ar+1,ar+m+1);
// fo(i,1,m)
// cout<<ar[i]<<sp;
// cout<<endl;
int l=0,r=min(m,n);
// fo(i,1,n)
// cout<<p[i].se<<sp;
// cout<<endl;
while(l<r)
{
if(r-l==1)
{
if(check(r))
l=r;
break;
}
// cout<<endl;
int mid=(l+r)/2;
// cout<<mid<<sp<<check(mid)<<endl;
if(check(mid))
l=mid;
else
r=mid-1;
}
cout<<l;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |