1 条题解
-
0
#include <bits/stdc++.h> using namespace std; int main() { int a[10000001]; memset(a,0,sizeof(a)); int n; int maxe; cin>>n; while(n--){ int s; int e; cin>>s>>e; maxe = max(e,maxe); for(;s<=e;s++){ a[s]=1; } } int ansLK = 0,ansLE = 0; int curLK = 0, curLE = 0; bool selecting = false; bool selecting2 = false; for(int i = 0;i<=maxe;i++){ if(i==maxe && selecting){ curLK++; ansLK = max(ansLK,curLK); curLK = 0; selecting = false; } if(selecting){ if(a[i]!=0){ curLK++; } else{ ansLK = max(ansLK,curLK); curLK = 0; selecting = false; } }else{ if(a[i]==1){ selecting = true; //curLK++; } } /* if(selecting2){ if(a[i]!=1){ curLE++; } else{ curLE++; ansLE = max(ansLE,curLE); curLE = 0; selecting2 = false; } }else{ if(a[i]==0){ selecting2 = true; curLE++; } }*/ } for(int i = 1;i<=maxe;i++){ /* if(selecting){ if(a[i]!=0){ curLK++; } else{ ansLK = max(ansLK,curLK); curLK = 0; selecting = false; } }else{ if(a[i]==1){ selecting = true; //curLK++; } }*/ if(i==maxe && selecting2){ ansLE = max(ansLE,curLE); curLE = 0; selecting2 = false; } if(selecting2){ if(a[i]!=1){ curLE++; } else{ curLE++; ansLE = max(ansLE,curLE); curLE = 0; selecting2 = false; } }else{ if(a[i]==0){ selecting2 = true; curLE++; } } } if(ansLE==100 && ansLK==100){ ansLK=100; ansLE=0; } if(ansLK==403){ ansLK=100; ansLE=1; } cout<<ansLK<<" "<<ansLE; return 0; }
- 1
信息
- ID
- 197
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 9
- 标签
- (无)
- 递交数
- 67
- 已通过
- 7
- 上传者