# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
120135 | Just_Solve_The_Problem | Exhibition (JOI19_ho_t2) | C++11 | 114 ms | 6712 KiB |
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 ll long long
#define ok puts("OK");
using namespace std;
const int N = (int)3e5 + 7;
int n, m;
int s[N], v[N], c[N], pos[N];
main() {
iota(pos, pos + N, 0);
scanf("%d %d", &n, &m);
vector <int> vec;
for (int i = 1; i <= n; i++) {
scanf("%d %d", &s[i], &v[i]);
vec.push_back(s[i]);
}
for (int i = 1; i <= m; i++) {
scanf("%d", &c[i]);
vec.push_back(c[i]);
}
sort(vec.begin(), vec.end());
vec.resize(unique(vec.begin(), vec.end()) - vec.begin());
for (int i = 1; i <= n; i++) {
s[i] = lower_bound(vec.begin(), vec.end(), s[i]) - vec.begin() + 1;
}
for (int i = 1; i <= m; i++) {
c[i] = lower_bound(vec.begin(),vec.end(), c[i]) - vec.begin() + 1;
}
sort(pos + 1, pos + n + 1, [&](const int &A, const int &B) {
if (v[A] == v[B]) {
return s[A] < s[B];
}
return v[A] < v[B];
});
sort(c + 1, c + m + 1);
int cur = n;
int ans = 0;
for (int i = m; i >= 1 && cur > 0; i--) {
while (cur > 0 && s[pos[cur]] > c[i]) {
cur--;
}
ans += (cur > 0);
cur--;
}
cout << ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |