0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-12-24 18:52:02 +00:00

P7913 [CSP-S 2021] 廊桥分配(民间数据)

R61098482
This commit is contained in:
Baoshuo Ren 2021-10-27 21:23:53 +08:00 committed by Baoshuo Ren
parent 2f7ec8ec7d
commit d0f33ab731
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

View File

@ -0,0 +1,33 @@
#include <bits/stdc++.h>
using namespace std;
int n, m[2], a, b, cnt[2][100005], ans;
set<pair<int, int>> s;
int main() {
cin >> n >> m[0] >> m[1];
for (int k = 0; k < 2; k++) {
for (int i = 1; i <= m[k]; i++) {
cin >> a >> b;
s.insert(make_pair(a, b));
}
for (int i = 1; i <= n; i++) {
int p = 0, c = 0;
while (true) {
auto it = s.lower_bound(make_pair(p, 0));
if (it == s.end()) break;
p = it->second;
s.erase(it);
c++;
}
cnt[k][i] = cnt[k][i - 1] + c;
}
s.clear();
}
for (int i = 0; i <= n; i++) {
ans = max(ans, cnt[0][i] + cnt[1][n - i]);
}
cout << ans << endl;
return 0;
}