1 條題解
-
0
#include<bits/stdc++.h> using namespace std; int a[1000005],d[1000005]; int n,A,B,minn,maxn,have,empty,ans_have,ans_empty,flag; int main(){ ios::sync_with_stdio(false); cin.tie(0),cout.tie(0); cin>>n; while(n--){ cin>>A>>B; d[A]++; d[B+1]--; minn=min(minn,A); maxn=max(maxn,B); } for(int i=minn;i<=maxn;i++){ a[i]=a[i-1]+d[i]; if(i>minn&&a[i]!=a[i-1])flag=1; //cout<<a[i]<<" "; if(a[i]){ have++; ans_empty=max(empty,ans_empty); empty=0; } if(!a[i]){ empty++; ans_have=max(have,ans_have); have=0; } } if(flag==1)cout<<ans_have-1<<" "<<ans_empty+1; else{ if(have)cout<<have<<" 0"; if(empty)cout<<"0 "<<empty; } return 0; }
- 1
資訊
- ID
- 778
- 時間
- 1000ms
- 記憶體
- 256MiB
- 難度
- 3
- 标签
- 遞交數
- 18
- 已通過
- 5
- 上傳者