| ||||||||||
| 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 | |||||||||
刚刚不是跟liard说了吗In Reply To:求救:怎么会错呢?谁能给出几组测试数据啊? Posted by:sidy at 2006-11-04 15:09:16 > #include<stdio.h>
> int main(){
> int i,p,q,num,N,a[100000],minlong,temp;
> __int64 S,sum;
> scanf("%d",&num);
> while(num--){
> scanf("%d%I64d",&N,&S);
> for(i=0; i<N; i++)scanf("%d",&a[i]);
> p=0; q=0; sum=0; temp=0;
> minlong=N;
> if(S==0)minlong=1;
> else{
> while(p<N){
> if(sum<S){
> if(q<N){
> sum+=a[q++];
> temp++;
> }
> else break;
> }
> else{
> if(temp<minlong)minlong=temp;
> sum-=a[p++];
> temp--;
> }
> }
> }
> printf("%d\n",minlong);
> }
> return 0;
> }
>
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator