为什么WA了?
#include <bits/stdc++.h>
using namespace std;
priority_queue <pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > > leave;
priority_queue <int,vector<int>,greater<int> > id;
int ci1[100005],ci2[100005];
int main (void) {
int n,m1,m2,all;
scanf ("%d%d%d",&n,&m1,&m2);
vector <pair <int,int> > v(m1);
for (int j = 0;j < m1;j++) {
int x,y;
scanf ("%d%d",&x,&y);
v[j].first = x;
v[j].second = y;
}
sort (v.begin(),v.end());
all = 0;
for (auto a : v) {
while (!leave.empty() && a.first >= leave.top().first) {
id.push(leave.top().second);
leave.pop();
}
if (id.empty()) id.push(all++);
int h = id.top();id.pop();
ci1[h]++;
leave.push(make_pair(a.second,h));
}
for (int j = 1;j < all;j++) ci1[j] += ci1[j-1];
v.resize(m2);
for (int j = 0;j < m2;j++) {
int x,y;
scanf ("%d%d",&x,&y);
v[j].first = x;
v[j].second = y;
}
sort (v.begin(),v.end());
leave = priority_queue <pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > >();
id = priority_queue <int,vector<int>,greater<int> >();
all = 0;
for (auto a : v) {
while (!leave.empty() && a.first >= leave.top().first) {
id.push(leave.top().second);
leave.pop();
}
if (id.empty()) id.push(all++);
int h = id.top();id.pop();
ci2[h]++;
leave.push(make_pair(a.second,h));
}
for (int j = 1;j < all;j++) ci2[j] += ci2[j-1];
int ans = 0;
for (int j = -1;j < n;j++) ans = max (ans,(j < 0 ? 0 : ci1[j]) + (n - j - 2 < 0 ? 0 : ci2[n-j-2]));
printf ("%d\n",ans);
return 0;
}