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 mp make_pair
#define pb push_back
#define fi first
#define se second
const int N = 100007;
int n, m, c[N];
pair <int, int> pic[N];
bool check(int x){
int cur = m - x + 1;
for(int i = 1; i <= n; i++){
if(cur > m) break;
if(pic[i].se <= c[cur]) cur++;
}
return (cur > m);
}
int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
cin >> n >> m;
for(int i = 1; i <= n; i++){
cin >> pic[i].se >> pic[i].fi;
}
for(int i = 1; i <= m; i++){
cin >> c[i];
}
sort(pic + 1, pic + 1 + n);
sort(c + 1, c + 1 + m);
int l = 0, r = min(n, m), mid = (l + r + 1) >> 1;
while(l < r){
if(check(mid)) l = mid;
else r = mid - 1;
mid = (l + r + 1) >> 1;
}
cout << l;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |