//Pantyhose(black) + glasses = infinity
#include <bits/stdc++.h>
using namespace std;
#define debug(x) cerr << #x << " = " << x << '\n';
#define BP() cerr << "OK!\n";
#define PR(A, n) {cerr << #A << " = "; for (int _=1; _<=n; ++_) cerr << A[_] << ' '; cerr << '\n';}
#define PR0(A, n) {cerr << #A << " = "; for (int _=0; _<n; ++_) cerr << A[_] << ' '; cerr << '\n';}
#define FILE_NAME "data"
const int MAX_N = 100002;
struct picture {
int sz, val;
};
int n, m, fr[MAX_N];
picture pic[MAX_N];
void readInput() {
cin >> n >> m;
for (int i=1; i<=n; ++i)
cin >> pic[i].sz >> pic[i].val;
for (int i=1; i<=m; ++i)
cin >> fr[i];
}
bool check(int cnt) {
int cur = m - cnt;
for (int i=1; i<=n; ++i) {
if (cur<m && pic[i].sz<=fr[cur+1])
++cur;
}
return cur==m;
}
void solve() {
sort(pic+1, pic+n+1, [](picture p1, picture p2) {
return p1.val < p2.val;
});
sort(fr+1, fr+m+1);
int l = 0, r = m;
for (int mid=(l+r)/2; mid!=l && r!=mid; mid=(l+r)/2) {
if (check(mid))
l = mid;
else
r = mid;
}
for (int i=r; i>=l; --i) {
if (check(i)) {
cout << i;
return;
}
}
}
int main() {
#ifdef GLASSES_GIRL
freopen(FILE_NAME".in", "r", stdin);
freopen(FILE_NAME".out", "w", stdout);
#endif
ios::sync_with_stdio(0); cin.tie(0);
readInput();
solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |