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;
const int N = 1e5 + 7;
struct Pic {
int sz, val;
bool operator < (Pic p) {
return val < p.val || (val == p.val && sz < p.sz);
}
};
Pic p[N];
int a[N], frame[N];
signed main() {
#ifdef HOME
freopen("input.txt", "r", stdin);
#else
ios_base::sync_with_stdio(0); cin.tie(0);
#endif
int n, m;
cin >> n >> m;
for (int i = 0; i < n; ++i) cin >> p[i].sz >> p[i].val;
for (int i = 0; i < m; ++i) cin >> frame[i];
sort(p, p + n); sort(frame, frame + m);
for (int i = 0; i < n; ++i) {
a[i] = lower_bound(frame, frame + m, p[i].sz) - frame;
}
int ans = 0;
for (int i = n - 1; i >= 0; --i) {
//ai + r < m
//ai + len <= m
//len <= m - ai
ans = max(ans, min(ans + 1, m - a[i]));
}
cout << ans << '\n';
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |