Submission #129393

#TimeUsernameProblemLanguageResultExecution timeMemory
129393souhhcongExhibition (JOI19_ho_t2)C++14
100 / 100
248 ms1680 KiB
#include <iostream> #include <algorithm> using namespace std; #define st first #define nd second const int N = 1e5+5; int n, m; pair<int,int> pic[N]; int frame[N]; bool check(int val) { int pos = val; for (int i = 0; i < n; i++) { if (pic[i].nd <= frame[pos]) { pos++; } } //cout << pos << endl; if (pos == m) return 1; return 0; } int main() { cin >> n >> m; for (int i = 0; i < n; i++) { cin >> pic[i].nd >> pic[i].st; } for (int i = 0; i < m; i++) { cin >> frame[i]; } sort(pic,pic+n); sort(frame,frame+m); int l = 0, r = m, mid, ans = 0; while(l != r) { mid = (l+r)/2; //cout << l << ' ' << mid << ' ' << r << endl; if (check(m-mid)) { ans = max(ans,mid); l = mid+1; } else r = mid; if (l == r) { if (check(m-l)) ans = max(ans,l); } } cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...