Submission #391898

#TimeUsernameProblemLanguageResultExecution timeMemory
391898lukameladzeExhibition (JOI19_ho_t2)C++14
100 / 100
162 ms5560 KiB
# include <bits/stdc++.h> #define f first #define s second #define pb push_back using namespace std; const int N=3e5+5; long long ff,b[N],ri,le,mid,n,m,ans; pair <long long , long long> a[N]; int check (int mid) { int le=1; int cnt=0; for (int i=m-mid+1; i<=m; i++) { ff=0; while (le<=n) { if (a[le].s<=b[i]) { cnt++; // cout<<a[le].s<<" "<<b[i]<<endl; ff=1; le++; break; } le++; } if (!ff) break; } if (!ff || cnt!=mid) return 0; else return 1; } int main() { cin>>n>>m; for (int i=1; i<=n; i++) { cin>>a[i].s>>a[i].f; } sort(a+1, a+n+1); for (int i=1; i<=m; i++) { cin>>b[i]; } sort(b+1, b+m+1); le=1; ri=n; while (le<=ri) { int mid=(le+ri)/2; if (check(mid)) { le=mid+1; ans=mid; } else { ri=mid-1; } } cout<<ans<<endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...