0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-30 16:36:26 +00:00

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

https://sjzezoj.com/submission/41499
This commit is contained in:
Baoshuo Ren 2021-10-30 19:14:27 +08:00 committed by Baoshuo Ren
parent 67cf3c995d
commit 3b4f5df33e
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

33
S2OJ/1122/1122.cpp Normal file
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;
}