hdu 1422 重温世界杯
http://acm.hdu.edu.cn/showproblem.php?pid=1422
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 #include <cstdio> 2 #include <cstring> 3 #include <algorithm> 4 #define maxn 200000 5 #define ll __int64 6 using namespace std; 7 8 ll w[maxn],l[maxn],c[maxn]; 9 int n; 10 11 int main() 12 { 13 while(scanf("%d",&n)!=EOF) 14 { 15 for(int i=0; i<n; i++) 16 { 17 scanf("%I64d%I64d",&w[i],&l[i]); 18 c[i]=w[i]-l[i]; 19 c[i+n]=c[i]; 20 } 21 ll ans=0; 22 int cnt=0; 23 int max1=0; 24 for(int i=0; i<2*n; i++) 25 { 26 ans+=c[i]; 27 cnt++; 28 if(ans<0) 29 { 30 ans=0; 31 cnt=0; 32 } 33 max1=max(max1,cnt); 34 if(cnt>=n) break; 35 } 36 printf("%d\n",max1>n?n:max1); 37 } 38 return 0; 39 }