记录编号 |
574103 |
评测结果 |
AAAAAAAAAAAAAAAAAAAA |
题目名称 |
[CSP 2021S]廊桥分配 |
最终得分 |
100 |
用户昵称 |
yrtiop |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
0.466 s |
提交时间 |
2022-07-30 13:23:27 |
内存使用 |
4.41 MiB |
显示代码纯文本
#include <bits/stdc++.h>
#define mp make_pair
#define fir first
#define sec second
using namespace std;
const int maxn = 1e5 + 5;
typedef pair<int,int> pii;
struct node {
int x,y;
node() {
x = y = 0;
}
}a[maxn],b[maxn];
int n,m,k;
int sum1[maxn],sum2[maxn];
priority_queue<pii,vector<pii>,greater<pii> > q;
priority_queue<int,vector<int>,greater<int> > s;
int main() {
freopen("2021airport.in","r",stdin);
freopen("2021airport.out","w",stdout);
scanf("%d %d %d",&n,&m,&k);
for(int i = 1;i <= m;++ i) {
scanf("%d %d",&a[i].x,&a[i].y);
}
sort(a + 1 , a + 1 + m , [&](const node& p,const node& q) {
return p.x < q.x;
});
for(int i = 1;i <= k;++ i) {
scanf("%d %d",&b[i].x,&b[i].y);
}
sort(b + 1 , b + 1 + k , [&](const node& p,const node& q) {
return p.x < q.x;
});
while(!q.empty())q.pop();
while(!s.empty())s.pop();
for(int i = 1;i <= m;++ i)s.push(i);
for(int i = 1;i <= m;++ i) {
for(;!q.empty()&&q.top().fir < a[i].x;q.pop())s.push(q.top().sec);
int ans = s.top();
s.pop();
++ sum1[ans];
q.push(mp(a[i].y , ans));
}
while(!q.empty())q.pop();
while(!s.empty())s.pop();
for(int i = 1;i <= k;++ i)s.push(i);
for(int i = 1;i <= k;++ i) {
for(;!q.empty()&&q.top().fir < b[i].x;q.pop())s.push(q.top().sec);
int ans = s.top();
s.pop();
++ sum2[ans];
q.push(mp(b[i].y , ans));
}
for(int i = 1;i <= n;++ i)sum1[i] += sum1[i - 1],sum2[i] += sum2[i - 1];
int ans = 0;
for(int i = 0;i <= n;++ i)ans = max(ans , sum1[i] + sum2[n - i]);
printf("%d\n",ans);
return 0;
}