Submission #116735

#TimeUsernameProblemLanguageResultExecution timeMemory
116735ZwariowanyMarcinExhibition (JOI19_ho_t2)C++14
100 / 100
80 ms4600 KiB
// #pragma GCC optimize("Ofast") #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define pb push_back #define ld long double #define fi first #define se second #define ll long long #define ss(x) (int) x.size() #define mp make_pair #define FOR(i, n) for(int i = 1; n >= i; ++i) using namespace std; using namespace __gnu_pbds; const int nax = 100005; int n, m; pair<int, int> t[nax]; int v[nax]; int f(int x) { int res = 0; int j = m - x + 1; for(int i = 1; i <= n; ++i) { if(j > m) break; if(t[i].fi <= v[j]) { ++res; ++j; } } return res == x; } int main() { cin.tie(0); ios_base::sync_with_stdio(0); cin >> n >> m; for(int i = 1; i <= n; ++i) { cin >> t[i].fi >> t[i].se; } for(int i = 1; i <= m; ++i) { cin >> v[i]; } sort(t + 1, t + n + 1, [](pair<int, int> a, pair<int, int> b) { if(a.se != b.se) return a.se < b.se; return a.fi < b.fi; }); sort(v + 1, v + m + 1); int l = 0, r = min(n, m); while(l < r) { int mid = (l + r + 1) / 2; if(f(mid)) l = mid; else r = mid - 1; } cout << l; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...