Submission #1098833

#TimeUsernameProblemLanguageResultExecution timeMemory
1098833serifefedartarExhibition (JOI19_ho_t2)C++17
0 / 100
1 ms604 KiB
#include <bits/stdc++.h> using namespace std; #define fast ios::sync_with_stdio(0);cin.tie(0) typedef long long ll; #define f first #define s second #define LOGN 21 const ll MOD = 1e9 + 7; const ll MAXN = 2e5 + 100; int n, m; vector<pair<int,int>> v1; vector<int> v2; bool check(int x) { vector<pair<int,int>> vv(v1.begin(), v1.end()); reverse(vv.begin(), vv.end()); vector<int> Q; for (int i = m - x; i < m; i++) Q.push_back(v2[i]); reverse(Q.begin(), Q.end()); while (vv.size() && Q.size()) { int x = vv.back().f; vv.pop_back(); if (Q.back() >= x) Q.pop_back(); } return Q.empty(); } int main() { fast; cin >> n >> m; v1 = vector<pair<int,int>>(n); v2 = vector<int>(m); for (int i = 0; i < n; i++) cin >> v1[i].f >> v1[i].s; for (int i = 0; i < m; i++) cin >> v2[i]; sort(v1.begin(), v1.end(), [&](pair<int,int> A, pair<int,int> B) { return A.s < B.s; }); sort(v2.begin(), v2.end()); int L = 1, R = min(n, m); int ans = 0; while (R >= L) { int mid = L + (R - L) / 2; if (check(mid)) { ans = mid; L = mid + 1; } else R = mid - 1; } cout << ans << "\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...