Submission #124714

#TimeUsernameProblemLanguageResultExecution timeMemory
124714Noam527Exhibition (JOI19_ho_t2)C++17
100 / 100
293 ms5416 KiB
#include <bits/stdc++.h> #define finish(x) return cout << x << endl, 0 typedef long long ll; typedef long double ldb; const int md = 1e9 + 7; const ll inf = 1e18; const int OO = 1; const int OOO = 1; using namespace std; int n, m; vector<pair<int, int>> a; vector<int> b; bool can(int x) { priority_queue<int, vector<int>, greater<int>> Q; int lst = -1, nxt = 0; for (int i = m - x; i < m; i++) { while (nxt < a.size() && a[nxt].first <= b[i]) { if (a[nxt].second >= lst) Q.push(a[nxt].second); nxt++; } if (!Q.size()) return false; lst = Q.top(); Q.pop(); } return true; } int main() { ios::sync_with_stdio(0), cin.tie(0); cin >> n >> m; a.resize(n); for (auto &i : a) cin >> i.first >> i.second; sort(a.begin(), a.end()); b.resize(m); for (auto &i : b) cin >> i; sort(b.begin(), b.end()); int lo = 0, hi = min(n, m), mid; while (lo < hi) { mid = (lo + hi + 1) / 2; if (can(mid)) lo = mid; else hi = mid - 1; } finish(lo); }

Compilation message (stderr)

joi2019_ho_t2.cpp: In function 'bool can(int)':
joi2019_ho_t2.cpp:19:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   while (nxt < a.size() && a[nxt].first <= b[i]) {
          ~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...