Run ID 作者 问题 语言 测评结果 时间 内存 代码长度 提交时间
85906 sh25_chenyj 钓鱼 C++ 无测评数据 0 MS 0 KB 2116 2026-03-20 20:45:22

Tests(0/0):


#include <iostream> #include <vector> #include <algorithm> #include <queue> using namespace std; // 结构体用于优先队列 struct Pond { int id; int fish; int decrease; // 构造函数,兼容老版本初始化 Pond(int _id, int _fish, int _decrease) : id(_id), fish(_fish), decrease(_decrease) {} // 优先队列大顶堆:产鱼量大的优先 bool operator<(const Pond& other) const { if (fish != other.fish) { return fish < other.fish; } return id > other.id; } }; int main() { // 移除 cin.tie(nullptr),改为 NULL 以兼容 ios::sync_with_stdio(false); cin.tie(NULL); int n, h; // 使用 while 处理输入更稳健 if (!(cin >> n >> h)) return 0; vector<int> f(n), d(n), t(n - 1); for (int i = 0; i < n; ++i) cin >> f[i]; for (int i = 0; i < n; ++i) cin >> d[i]; for (int i = 0; i < n - 1; ++i) cin >> t[i]; int total_intervals = h * 12; int max_fish_all_cases = 0; int travel_time_sum = 0; for (int k = 0; k < n; ++k) { if (k > 0) { travel_time_sum += t[k - 1]; } int remaining_time = total_intervals - travel_time_sum; if (remaining_time <= 0) break; priority_queue<Pond> pq; for (int i = 0; i <= k; ++i) { if (f[i] > 0) { // 使用构造函数代替列表初始化 pq.push(Pond(i, f[i], d[i])); } } int current_case_fish = 0; int time_left = remaining_time; while (time_left > 0 && !pq.empty()) { Pond top = pq.top(); pq.pop(); current_case_fish += top.fish; top.fish -= top.decrease; if (top.fish > 0) { pq.push(top); } time_left--; } if (current_case_fish > max_fish_all_cases) { max_fish_all_cases = current_case_fish; } } cout << max_fish_all_cases << endl; return 0; }