This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// #pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define ld long double
#define fi first
#define se second
#define ll long long
#define ss(x) (int) x.size()
#define mp make_pair
#define FOR(i, n) for(int i = 1; n >= i; ++i)
using namespace std;
using namespace __gnu_pbds;
const int nax = 100005;
int n, m;
pair<int, int> t[nax];
int v[nax];
int f(int x) {
int res = 0;
int j = m - x + 1;
for(int i = 1; i <= n; ++i) {
if(j > m)
break;
if(t[i].fi <= v[j]) {
++res;
++j;
}
}
return res == x;
}
int main() {
cin.tie(0);
ios_base::sync_with_stdio(0);
cin >> n >> m;
for(int i = 1; i <= n; ++i) {
cin >> t[i].fi >> t[i].se;
}
for(int i = 1; i <= m; ++i) {
cin >> v[i];
}
sort(t + 1, t + n + 1, [](pair<int, int> a, pair<int, int> b) {
if(a.se != b.se)
return a.se < b.se;
return a.fi < b.fi;
});
sort(v + 1, v + m + 1);
int l = 0, r = min(n, m);
while(l < r) {
int mid = (l + r + 1) / 2;
if(f(mid))
l = mid;
else
r = mid - 1;
}
cout << l;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |