| ||||||||||
| 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 | |||||||||
Re:大侠帮我看看。。到底啥毛病啊。。过不了In Reply To:大侠帮我看看。。到底啥毛病啊。。过不了 Posted by:782423381 at 2009-08-05 14:58:43 > #include<iostream>
> using namespace std;
> int f[25],d[25],t[25],tf[25],td[25],ti[25],tti[25];
> int main()
> {
> int c,n,h,th,i,j,ans,tans,maxf,tt;
> //scanf("%d",&c);
> tt=0;
> // while(c--)
> //{
> while(scanf("%d",&n),n)
> {
> if(tt++) printf("\n");//输入+时间转换
> scanf("%d",&h);
> h=h*60;
> for(i=0;i<n;i++)
> scanf("%d",f+i);
> for(i=0;i<n;i++)
> scanf("%d",d+i);
> for(i=1;i<n;t[i]*=5,i++)
> scanf("%d",t+i);
> t[0]=0;
> ans=-1;
> memset(ti,0,sizeof(ti));
> for(i=0;i<n;i++)
> {
> memset(tti,0,sizeof(tti));
> tans=0;
> th=h;
> for(j=0;j<=i;j++)
> {
> if(th<0) break;
> tf[j]=f[j];
> td[j]=d[j];
> th-=t[j];
>
> }
>
> while(th>0)
> {
> maxf=0;
> for(j=1;j<=i;j++)
> if(tf[maxf]<tf[j]) maxf=j;
> tans+=tf[maxf];
> tf[maxf]-=td[maxf];
> if(tf[maxf]<=0)
> {
>
> tf[maxf]=0;
> }
> th-=5;
>
> tti[maxf]+=5;
>
> }
> if(tans>ans)
> {
> ans=tans;
> for(j=0;j<=i;j++)
> ti[j]=tti[j];
> }
> if(tans==ans)
> {
> for(j=0;j<=i;j++)
> {
> if(tti[j]!=ti[j]) break;
> }
> if(ti[j]<tti[j])
> {
> for(int m=j;m<=i;m++)
> ti[m]=tti[m];
> }
> }
>
> }
> for(i=0;i<n-1;i++)
> printf("%d, ",ti[i]);
> printf("%d\nNumber of fish expected: %d\n",ti[n-1],ans);
>
> }
> //}
> return 0;
> }
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator