Submission #129436

#TimeUsernameProblemLanguageResultExecution timeMemory
129436shuvi_dolaExhibition (JOI19_ho_t2)C++14
0 / 100
2 ms376 KiB
#include <bits/stdc++.h> using namespace std; const int N = 1e5+4; int fr[N]; int n, m; struct pic { int sz, v; } a[N]; bool cmp(pic a, pic b) { if(a.v == b.v) return a.sz > b.sz; return a.v > b.v; } bool ck(int len) { int j = m; for(int i=1;i<=n;i++) { // cout<<a[i].sz<<' '<<fr[j]<<'\n'; if(a[i].sz <= fr[j]) { j--; if(j == m-len) return true; } } return false; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cin>>n>>m; for(int i=1;i<=n;i++) { cin>>a[i].sz>>a[i].v; } for(int i=1;i<=m;i++) { cin>>fr[i]; } // cout<<fr[1]<<' '<<fr[2]; sort(a+1,a+1+n,cmp); sort(fr+1,fr+1+m); // cout<<ck(2); int L = 0, R = min(n, m), res = 0; while(L <= R) { int mid = (L+R)/2; // cout<<mid<<'\n'; // cout<<L<<' '<<R<<' '<<mid<<'\n'; if(ck(mid) == true) { res = max(res ,mid); L = mid+1; } else R = mid-1; } cout<<res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...