제출 #99730

#제출 시각아이디문제언어결과실행 시간메모리
99730FashoExhibition (JOI19_ho_t2)C++14
100 / 100
87 ms2812 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...