Submission #990452

#TimeUsernameProblemLanguageResultExecution timeMemory
990452IWTIMExhibition (JOI19_ho_t2)C++17
100 / 100
114 ms5972 KiB
#include<bits/stdc++.h> using namespace std; const int N=3e5+5; int cur, x, n, c[N],m; pair <int, int> a[N]; int check(int mid) { cur = 1; for (int i=m-mid+1; i <= m; i++) { x = 0; while (cur <= n) { if (a[cur].second<=c[i]) { x=1; cur++; break; } else cur++; } if (x==0){ return 0; } } return 1; } int main(){ cin>>n>>m; for (int i=1; i<=n; i++){ cin>>a[i].second; // zoma cin>>a[i].first; // value } sort (a+1, a+n+1); for (int i=1; i<=m; i++){ cin>>c[i]; } sort (c+1, c+m+1); int l=1; int r=min(n,m); int ans = 0; while (l<=r) { int mid=(l+r)/2; if (check(mid)) { ans=mid; l=mid+1; } else { r=mid-1; } } cout<<ans<<endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...