#include <bits/stdc++.h>
using namespace std;
const int maxL = 30;
int f[maxL];
int d[maxL];
int t[maxL];
int maxFishes = -1;
int lakeTime[maxL];
int bestLakeTime[maxL];
struct Lake{
int No;
int f;
bool operator < (const Lake & l) const
{
if(f == l.f) return No > l.No;
return f < l.f;
}
};
int main()
{
int n, h;
while(scanf("%d", &n) != EOF){
if(n == 0) break;
maxFishes = -1;
// cin >> h;
scanf("%d", &h);
int i;
for(i = 1; i <= n; i++){
// cin >> f[i];
scanf("%d", &f[i]);
}
for(i = 1; i <= n; i++){
// cin >> d[i];
scanf("%d", &d[i]);
}
for(i = 1; i < n; i++){
// cin >> t[i];
scanf("%d", &t[i]);
}
int end;
for(end = 1; end <= n; end++){
int total = 0;
memset(lakeTime, 0, sizeof(lakeTime));
int workTime = h * 60 / 5;
int i;
for(i = 1; i < end; i++){
workTime -= t[i];
}
priority_queue<Lake> pq;
for(i = 1; i <= end; i++){
pq.push(Lake{i, f[i]});
}
int t;
for(t = 1; t <= workTime; t++){
Lake lk = pq.top();
pq.pop();
total += lk.f;
++lakeTime[lk.No];
if(lk.f >= d[lk.No]) lk.f -= d[lk.No];
else lk.f = 0;
pq.push(lk);
}
if(total > maxFishes){
maxFishes = total;
memcpy(bestLakeTime, lakeTime, sizeof(lakeTime));
}else if(total == maxFishes){
int i;
for(i = 1; i <= n; i++){
if(lakeTime[i] > bestLakeTime[i]){
memcpy(bestLakeTime, lakeTime, sizeof(lakeTime));
break;
}else if(lakeTime[i] < bestLakeTime[i]) break;
}
}
}
for(i = 1; i <= n; i++){
if(i != n) printf("%d, ", bestLakeTime[i] * 5);
else printf("%d\n", bestLakeTime[i] * 5);
}
printf("Number of fish expected: ");
printf("%d\n\n", maxFishes);
}
return 0;
}
百練1042:Gone Fishing
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.