#include<iostream>
#include<cstdio>
using namespace std;
int input[200005];
int main()
{
int n,i,w,l,ans,tmp,tmp2;
while(scanf("%d",&n)!=EOF)
{
for(i=0;i<n;++i)
{
// cin>>w>>l;
scanf("%d %d",&w,&l);
input[i]=input[i+n]=w-l;
}
ans=0,tmp=0,tmp2=0;
for(i=0;i<2*n;++i)
{
tmp+=input[i];
if(tmp<0)
{
tmp=0;
tmp2=0;
}
else
{
tmp2++;
if(tmp2>ans)
ans=tmp2;
}
}
if(ans>n)
ans=n;
// cout<<ans<<endl;
printf("%d\n",ans);
}
return 0;
}
hdu 1422 最大子序列和问题的变形,最长非负子序列
最新推荐文章于 2021-05-22 22:29:28 发布