Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

求救:怎么会错呢?谁能给出几组测试数据啊?

Posted by sidy at 2006-11-04 15:09:16 on Problem 3061
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator