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 zerocool_08 at 2005-07-13 10:58:09 on Problem 2465
#include "iostream.h"
int main(void)
{
	int	a[102][201]={0};
	int	ln,s[102]={0},w[102]={0},i=0,j,k,l,min;
	cin>>ln;
	while(cin>>s[i]>>w[i]&&s[i]<=ln)
		i++;
	s[i]=ln+100;
	cout<<i;
	if(i==0||s[0]>100||ln-s[i-1]>100)
	{	
		cout<<"Impossbile"<<endl;
		return  0;
	}
	for(j=1;j<i;j++)
	{
		if(s[j]-s[j-1]>200)
		{	cout<<"Impossbile"<<endl;
			return  0;		
		}
	}
	for(j=0;j<=100-s[0];j++)
		;
	if(s[0]==0)
	{
		for(;j<=200;j++)
			a[0][j]=w[0]*(j-100);
	}
	else
	{
		for(;j<=200;j++)
		a[0][j]=-1;
	}
	for(k=1;k<i;k++)  
	{
		for(j=0;j<=200-s[k]+s[k-1];j++)
		{
			for(l=0,min=2000000000;a[k-1][l]>=0&&l<=200;l++)
			{
				if(s[k]+j-s[k-1]-l<=0)
				{		if(a[k-1][l]<min)
						min=a[k-1][l];
				}
				else
					if((s[k]-s[k-1]-l+j)*w[k-1]+a[k-1][l]<min)
						min=(s[k]-s[k-1]-l+j)*w[k-1]+a[k-1][l];
			}
			a[k][j]=min;
		}
		for(;j<=200;j++)
			a[k][j]=-1;
	}
	for(l=0,min=2000000000;a[k-1][l]>=0&&l<=200;l++)
			{
				if(s[k]-s[k-1]-l<=0)
				{		if(a[k-1][l]<min)
						min=a[k-1][l];
				}
				else
					if((s[k]-s[k-1]-l)*w[k-1]+a[k-1][l]<min)
						min=(s[k]-s[k-1]-l)*w[k-1]+a[k-1][l];
			}
			a[k][0]=min;		
	cout<<a[i][0];
	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