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 |
能找到的数据都没问题,为什么就是WA啊!!恳请哪位大大帮忙看下吧#include <iostream> using namespace std; #define MAX 30 int n,h; int f[MAX]; int d[MAX]; int t[MAX];//t[i]表示到达第i个湖在路上所花费时间,与题目的ti不同 int sum[MAX];//sum[i]表示终点为第i个湖所能钓到的最多数目 int time[MAX][MAX];//sum[i][j]表示终点为第个湖的情况在第j个湖所消耗的时间 int pos;//达到第pos个湖所能钓到的鱼最多 void solve(){ int i,j,k,max,tempPos,tempH; int now[MAX];//当前各个湖所能钓到的鱼个数 for(i=1;i<=n;i++){ tempH=h-t[i]; //cout<<tempH<<endl; for(j=1;j<=i;j++) now[j]=f[j]; while(tempH>0){ tempH--; max=0; for(j=1;j<=i;j++) if(max<now[j]){ max=now[j]; tempPos=j; } if(max==0)//1~i个湖的所有鱼已经钓完 break; time[i][tempPos]++; sum[i]+=max; now[tempPos]-=d[tempPos]; } } pos=1; for(i=2;i<=n;i++) if(sum[i]>sum[pos]) pos=i; } int main(){ int i,temp; while(scanf("%d",&n)!=EOF&&n){ scanf("%d",&h); h*=12; memset(t,0,sizeof(t)); memset(sum,0,sizeof(sum)); memset(time,0,sizeof(time)); for(i=1;i<=n;i++) scanf("%d",&f[i]); for(i=1;i<=n;i++) scanf("%d",&d[i]); for(i=2;i<=n;i++){ scanf("%d",&temp); t[i]=t[i-1]+temp; } solve(); printf("%d",time[pos][1]*5); for(i=2;i<=n;i++) printf(", %d",time[pos][i]*5); printf("\nNumber of fish expected: %d\n\n",sum[pos]); } system("pause"); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator