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 int long long
const int N = 1e5;
int n, m, S[N + 5], V[N + 5], C[N + 5], arr[N + 5];
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n >> m;
for (int i = 1; i <= n; i++) cin >> S[i] >> V[i];
for (int i = 1; i <= m; i++) cin >> C[i];
for (int i = 1; i <= n; i++) arr[i] = i;
sort(arr + 1, arr + n + 1, [&](int a, int b) {
if (V[a] == V[b]) return S[a] < S[b];
else return V[a] < V[b];
});
sort(C + 1, C + m + 1);
int ans = 0, index = n;
for (int i = m; i >= 1; i--) {
while (index && S[arr[index]] > C[i]) index--;
if (!index) break;
if (S[arr[index]] <= C[i]) index--, ans++;
}
cout << ans << '\n';
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... |