#include<cstdlib>
#include<iostream>
#include<cstdio>
#include<cmath>
#include<set>
#include<cstring>
#include <algorithm>
#define inf 0x7fffffff
#define N 30
#define MIN 1e-11
#define M 10000
#define LL long long
using namespace std;
int n,k,h;
int f[N],d[N],t[N],ff[N],ansh[N],temp[N];
int main()
{
#ifndef ONLINE_JUDGE
freopen("ex.in","r",stdin);
#endif
// scanf("%d%*c%*c",&t);
int x=0;
while(scanf("%d",&n)&&n)
{
if(x)
printf("\n");
else
x=1;
int maxv=-1;
scanf("%d",&h);
h*=12;
for(int i=0; i<n; ++i)
scanf("%d",&f[i]);
for(int i=0; i<n; ++i)
scanf("%d",&d[i]);
t[0]=0;
for(int i=1; i<n; ++i)
{
scanf("%d",&t[i]);
t[i]+=t[i-1];
}
int hh;
for(int i=0; i<n && t[i] <= h; i++)
{
memcpy(ff,f,sizeof(f));
int cnt=0;//
hh=h-t[i];
if(hh<0)
break;
memset(temp,0,sizeof(temp));
while(hh)//多的时间正好给了第一个
{
int num=-1,sub;
for(int j=0; j<=i; j++)
{
if(ff[j]>num)
{
sub=j;
num=ff[j];
}
}
temp[sub]++;
cnt+=num;
ff[sub]-=d[sub];
if(ff[sub]<0)
ff[sub]=0;
hh--;
}
if(maxv<cnt)
{
maxv=cnt;
memcpy(ansh,temp,sizeof(temp));
}
else if(maxv==cnt)
{
for(int k=0; k<=i; k++)
{
if(ansh[k]>temp[k])//k写成i,wa了n次!!!
break;
else if(ansh[k]<temp[k])
{
memcpy(ansh,temp,sizeof(temp));
break;
}
}
}
}
printf("%d",ansh[0]*5);
for(int i=1; i<n; i++)
printf(", %d",ansh[i]*5);
printf("\nNumber of fish expected: %d\n",maxv);
}
return 0;
}
uva757 - Gone Fishing--------好题!!(思路很重要)
最新推荐文章于 2017-07-15 19:03:31 发布