# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
125826 | EntityIT | Exhibition (JOI19_ho_t2) | C++14 | 303 ms | 5464 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
const int N = (int)1e5 + 5, M = N;
int n, m, c[M];
pair<int, int> picture[N];
bool check (int mid) {
priority_queue<int, vector<int>, greater<int> > pq;
int iPicture = 1, cur = 0;
for (int i = m - mid + 1; i <= m; ++i) {
while (iPicture <= n && picture[iPicture].fi <= c[i]) {
pq.push(picture[iPicture].se);
++iPicture;
}
while (!pq.empty() && pq.top() < cur) pq.pop();
if (pq.empty() ) return false ;
cur = pq.top(); pq.pop();
}
return true ;
}
int main () {
scanf("%d %d", &n, &m);
for (int i = 1; i <= n; ++i) scanf("%d %d", &picture[i].fi, &picture[i].se);
for (int i = 1; i <= m; ++i) scanf("%d", c + i);
sort(picture + 1, picture + n + 1);
sort(c + 1, c + m + 1);
int lAns = 0, rAns = min(n, m);
while (lAns < rAns) {
int mid = (lAns + rAns + 1) >> 1;
if (check(mid) ) lAns = mid;
else rAns = mid - 1;
}
cout << lAns;
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |