优先队列,手写
#include<iostream>
#include<cstdio>
using namespace std;
int n,T,k,mx;
struct HP{
int f,d,t;
}hp[30],nod[30],nd;
void mat(int t)
{
int now=t;
int tp=2*now;
while(tp<=k)
{
if(tp<k && hp[tp].f<hp[tp+1].f) tp=tp+1;
if(hp[tp].f>hp[now].f)
{
nd=hp[now];
hp[now]=hp[tp];
hp[tp]=nd;
now=tp;
}
else break;
}
}
int main()
{
scanf("%d%d",&n,&T);
int tim=T*60/5;//向下取整
for(int i=1;i<=n;i++) scanf("%d",&nod[i].f);
for(int i=1;i<=n;i++) scanf("%d",&nod[i].d);
for(int i=2;i<=n;i++)
{
scanf("%d",&nod[i].t);
nod[i].t+=nod[i-1].t;//nod[3].t
}
// for(int i=1;i<=n;i++) cout<<nod[i].t<<" ";//检查时间加和是否正确
for(k=1;k<=n;k++) //枚举最终走到哪个池塘
{
int sm=0;
int st=tim-nod[k].t;
if(st<=0) continue;
for(int j=1;j<=k;j++) hp[j]=nod[j];
for(int i=1;i<=k/2;i++) mat(i); //建堆
// cout<<hp[1].f<<endl;//这里检查大根堆是否正确
while(st && hp[1].f)
{
sm+=hp[1].f;
hp[1].f-=hp[1].d;
mat(1);
st--;
}
if(sm>mx) mx=sm;
}
cout<<mx<<endl;
}