洛谷P1717 钓鱼

 1 #include<iostream>
 2 #include<cstdio>
 3 #include<queue>
 4 #include<utility>
 5 using namespace std;
 6 int n,h,f[100],d[100],t[100],ans,Time,nowt;
 7 typedef pair<int,int> P;
 8 priority_queue<P>q;
 9 int main()
10 {
11     scanf("%d%d",&n,&h);
12     h*=12;
13     for(int i=1;i<=n;i++) scanf("%d",&f[i]);
14     for(int i=1;i<=n;i++) scanf("%d",&d[i]);
15     for(int i=1;i<=n-1;i++) scanf("%d",&t[i]);
16     for(int i=1;i<=n;i++)
17     {
18         Time=h-nowt;
19         nowt+=t[i];
20         int now=0;
21         while(!q.empty()) q.pop();
22         for(int j=1;j<=i;j++) q.push(make_pair(f[j],j));
23         while(Time>0&&!q.empty()&&q.top().first>0)
24         {
25             P top=q.top();q.pop();
26             Time--;
27             now+=top.first;
28             top.first-=d[top.second];
29             q.push(top);
30         }
31         ans=max(ans,now);
32     }
33     printf("%d",ans);
34     return 0;
35 }
原文地址:https://www.cnblogs.com/yu-xing/p/10198218.html