# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1232946 | CrabCNH | Exhibition (JOI19_ho_t2) | C++20 | 35 ms | 4420 KiB |
#include <bits/stdc++.h>
#define task "BriantheCrab"
#define int long long
#define pii pair <int, int>
#define fi first
#define se second
#define szf sizeof
#define sz(s) (int)((s).size())
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using namespace std;
template <class T> void minimize (T &t, T f) {if (t > f) t = f;}
template <class T> void maximize (T &t, T f) {if (t < f) t = f;}
const int maxN = 2e5 + 5;
const int inf = 1e18 + 7;
const int mod = 1e9 + 7;
// khong tu code thi khong kha len duoc dau
int n, m;
int s[maxN], v[maxN], c[maxN];
void solve () {
priority_queue <pii> pq;
cin >> n >> m;
for (int i = 1; i <= n; i ++) {
cin >> s[i] >> v[i];
pq.push ({v[i], s[i]});
}
for (int i = 1; i <= m; i ++) {
cin >> c[i];
}
sort (c + 1, c + m + 1, greater <int> ());
int res = 0;
for (int i = 1; i <= m; i ++) {
while (sz (pq) && pq.top ().se > c[i]) {
pq.pop ();
}
if (sz (pq)) {
res ++;
pq.pop ();
}
else {
break;
}
}
cout << res;
return;
}
signed main () {
cin.tie (nullptr) -> sync_with_stdio (false);
if (fopen (task".inp", "r")) {
freopen (task".inp", "r", stdin);
freopen (task".out", "w", stdout);
}
int t = 1;
//cin >> t;
while (t --) {
solve ();
}
return 0;
}
// thfv
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... |