Submission #532852

#TimeUsernameProblemLanguageResultExecution timeMemory
532852amunduzbaevExhibition (JOI19_ho_t2)C++17
0 / 100
1 ms204 KiB
#include "bits/stdc++.h" using namespace std; #define ar array #define int long long signed main(){ ios::sync_with_stdio(0); cin.tie(0); int n, m; cin>>n>>m; vector<int> s(n), v(n), c(m), p(n); for(int i=0;i<n;i++) cin>>s[i]>>v[i], p[i] = i; sort(p.begin(), p.end(), [&](int i, int j){ return (v[i] < v[j]); }); for(int i=0, last=0;i<n;){ int j=i; while(j<n && v[p[i]] == v[p[j]]) j++; while(i<j) v[p[i++]] = last; last++; } for(int i=0;i<m;i++){ cin>>c[i]; } sort(c.begin(), c.end()); vector<int> left(n); for(int i=0;i<n;i++){ left[i] = m - (int)(lower_bound(c.begin(), c.end(), s[i]) - c.begin()) - 1; } vector<ar<int, 2>> t(n); for(int i=0;i<n;i++) t[i] = {v[p[i]], left[p[i]]}; for(int i=0;i<n;i++) v[i] = t[i][0], left[i] = t[i][1]; auto check = [&](int k){ int mx = 0; for(int i=0;i<n;i++){ if(left[i] == -1) continue; int p = max(1ll, k - left[i]); if(p <= mx + 1) mx++; } return (mx >= k); }; int l = 0, r = n; while(l < r){ int m = (l + r + 1) >> 1; if(check(m)) l = m; else r = m - 1; } cout<<l<<"\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...