| ||||||||||
| 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 | |||||||||
能不能帮我看看我这个错在哪了#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator