| ||||||||||
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 |
怎么能WA呢???????????#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