0
已解决
周琪岳
资深光能
资深光能
H2萌新求助
WA5个点,谢谢各位
#include <iostream>
#include <string>
#include <cstdio>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;
int n,s_in,e_in,s=0x3f3f3f3f,e=-0x3f3f3f3f;
bool a[1000005];
int you[1000005],wu[1000005],ans1=-1,ans2=-1;
int main(){
cin>>n;
for(int i=1;i<=n;i++){
cin>>s_in>>e_in;
s=min(s,s_in);e=max(e,e_in);
for(int j=s_in;j<=e_in;j++){
a[j]=true;
}
}
for(int i=s;i<=e;i++){
if(a[i]==true){
you[i]=you[i-1]+1;
} else{
wu[i]=wu[i-1]+1;
}
ans1=max(ans1,you[i]);
ans2=max(ans2,wu[i]);
}
cout<<ans1-1<<" "<<ans2+1;
return 0;
}