Submission #825467

#TimeUsernameProblemLanguageResultExecution timeMemory
825467taherExhibition (JOI19_ho_t2)C++17
100 / 100
55 ms5740 KiB
#include <bits/stdc++.h> using namespace std; #ifdef LOCAL #include "C:\GCC\debug.h" #else #define debug(...) void(42) #endif int main() { ios::sync_with_stdio(false); cin.tie(0); int n, m; cin >> n >> m; vector<array<int, 2>> a(n); for (int i = 0; i < n; i++) { cin >> a[i][1] >> a[i][0]; } sort(a.begin(), a.end()); vector<int> c(m); for (int i = 0; i < m; i++) { cin >> c[i]; } sort(c.begin(), c.end()); vector<int> sizes(n); for (int i = 0; i < n; i++) { sizes[i] = a[i][1]; } auto Check = [&](int p) { int l = m - p, r = m - 1; vector<int> cur; for (int i = l; i <= r; i++) { cur.push_back(c[i]); } reverse(cur.begin(), cur.end()); int ptr = 0; while (ptr < n && (int) cur.size() > 0) { if (sizes[ptr] <= cur.back()) { cur.pop_back(); } ptr++; } return (cur.empty()); }; int low = 0, high = m; while (low <= high) { int mid = low + (high - low) / 2; if (Check(mid)) { low = mid + 1; } else { high = mid - 1; } } --low; cout << low << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...