#include <iostream>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
using namespace std;
#define MAXN 30
int ans[MAXN], tmp[MAXN];
int h, n;
struct node
{
int no, rate, cut, time;
friend bool operator <( const node&a, const node &b)
{
if(a.rate != b.rate)
return a.rate < b.rate;
return a.no > b.no;
}
}arr[MAXN];
priority_queue<node>que;
void fan( )
{
int maxsum = -10000;
for( int i = 0; i < n; i++)
{
while(!que.empty()) que.pop();
for(int j = 0; j <= i; j++) que.push(arr[j]);
int lefttime = h*60 - arr[i].time, sum = 0;
memset(tmp, 0, sizeof(tmp));
while(lefttime > 0)
{
node temp = que.top();
que.pop();
if(temp.rate <= 0) break;
sum += temp.rate;
temp.rate -= temp.cut;
tmp[temp.no] += 5;
que.push(temp);
lefttime -= 5;
}
if(lefttime > 0)
tmp[0] += lefttime;
if(sum > maxsum)
{
maxsum = sum;
for( int j = 0; j < n; j++)
ans[j] = tmp[j];
}
}
printf("%d",ans[0]);
for(int i = 1; i<n; ++i)
printf(", %d",ans[i]);
printf("\n");
printf("Number of fish expected: %d\n", maxsum);
}
int main()
{
bool flag = false;
while(scanf("%d",&n) != EOF && n)
{
scanf("%d",&h);
for( int i = 0; i < n; i++)
{
scanf("%d",&arr[i].rate);
arr[i].no = i;
}
for( int i = 0; i < n; i++)
scanf("%d",&arr[i].cut);
arr[0].time = 0;
for( int i = 1; i < n; i++)
{
scanf("%d",&arr[i].time);
arr[i].time = arr[i-1].time + arr[i].time * 5;
}
if(flag) printf("\n");
flag = true;
fan();
}
return 0;
}
UVA 757
最新推荐文章于 2019-04-29 13:34:38 发布