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>
#define int long long
// #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()
#define kill(x) cout << x << "\n", exit(0);
#define pii pair<int, int>
#define endl "\n"
using namespace std;
typedef long long ll;
// typedef __int128_t lll;
typedef long double ld;
const int MAXN = (int)1e6 + 7;
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18 + 7;
int n, m, k, tmp, t, tmp2, tmp3, tmp4, u, v, w, flag, q, ans, flag2;
pii arr[MAXN];
int arr2[MAXN];
bool check(int k) {
int j = m-k+1;
for (int i=1; i<=n; i++) {
if (arr[i].S <= arr2[j]) j++;
if (j > m) return 1;
}
return 0;
}
int32_t main() {
#ifdef LOCAL
freopen("inp.in", "r", stdin);
freopen("res.out", "w", stdout);
#else
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#endif
cin >> n >> m;
for (int i=1; i<=n; i++) cin >> arr[i].S >> arr[i].F;
sort(arr+1, arr+n+1);
for (int i=1; i<=m; i++) cin >> arr2[i];
sort(arr2+1, arr2+m+1);
if (check(m)) kill(m);
int l, r, mid;
l = 0; r = m;
while (r-l > 1) {
mid = (l+r)/2;
if (check(mid)) l = mid;
else r = mid;
}
cout << l << endl;
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... |