| ||||||||||
Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
Re:怎么能WA呢???????????In Reply To:怎么能WA呢??????????? Posted by:tcxgsy at 2006-11-04 18:53:07 > #include<iostream> > using namespace std; > int a[100002]; > int main() > { > int tests; > int m,n; > int i,j; > int sum; > > cin>>tests; > while(tests--) > { > cin>>m>>n; > for(i=0;i<m;i++) > cin>>a[i]; > i=0; > int min=1000000; > sum=0; > j=0; > while(j<=i&&i<=m) > { > > if(sum<n) {sum+=a[i];i++;} > if(sum>=n) { > if(i-j<min) min=i-j; > sum-=a[j]; > j++; > } > } > if(min==m&&sum<n) > cout<<0<<endl; > else > cout<<min<<endl; > } > return 1; > } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator