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 <iostream>
#include <iomanip>
#include <fstream>
#include <vector>
#include <array>
#include <algorithm>
#include <utility>
#include <map>
#include <queue>
#include <set>
#include <cmath>
#include <cstdio>
#include <cstring>
#define ll long long
#define ld long double
#define eps 1e-8
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3f
// change if necessary
#define MAXN 100010
using namespace std;
int n, m;
pair<int, int> paint[MAXN];
int frame[MAXN];
int main() {
cin.tie(0)->sync_with_stdio(0);
cin >> n >> m;
for (int i = 0; i < n; i++) {
cin >> paint[i].first >> paint[i].second;
}
for (int i = 0; i < m; i++) {
cin >> frame[i];
}
sort(paint, paint + n, [](const pair<int, int> &p1, const pair<int, int> &p2) {
if (p1.second == p2.second) return p1.first < p2.first;
return p1.second < p2.second;
});
sort(frame, frame + m);
int cur_p = n - 1;
int ans = 0;
for (int i = m - 1; i >= 0; i--) {
while (cur_p >= 0 && paint[cur_p].first > frame[i]) cur_p--;
if (cur_p >= 0) {
ans++;
cur_p--;
}
}
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... |