이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |