许诺 • 2个月前
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
struct Lake {
int curr_fish;
int di;
Lake(int f, int d) : curr_fish(f), di(d) {}
bool operator<(const Lake& other) const {
return curr_fish < other.curr_fish;
}
};
int main() {
int n, h;
cin >> n >> h;
vector<int> fi(n);
vector<int> di(n);
vector<int> ti(n - 1);
for (int i = 0; i < n; ++i) {
cin >> fi[i];
}
for (int i = 0; i < n; ++i) {
cin >> di[i];
}
for (int i = 0; i < n - 1; ++i) {
cin >> ti[i];
}
h *= 12;
int max_fish = 0;
for (int k = 1; k <= n; ++k) {
int move_time = 0;
for (int i = 0; i < k - 1; ++i) {
move_time += ti[i];
}
int remain = h - move_time;
if (remain <= 0) continue;
priority_queue<Lake> pq;
for (int i = 0; i < k; ++i) {
pq.push(Lake(fi[i], di[i]));
}
int total = 0;
for (int i = 0; i < remain; ++i) {
if (pq.empty()) break;
Lake lake = pq.top();
pq.pop();
total += lake.curr_fish;
int next_fish = lake.curr_fish - lake.di;
if (next_fish > 0) {
pq.push(Lake(next_fish, lake.di));
}
}
if (total > max_fish) {
max_fish = total;
}
}
cout << max_fish << endl;
return 0;
}
评论:
请先登录,才能进行评论