cc
Posted by tiendatCT1
at 2023-03-27 11:21:45
#include <bits/stdc++.h> using namespace std; int n,i,j,H,res; int f[100005],d[100005],v[100005],t[100005]; void doc() { cin >> n >> H; for(i=1;i<=n-1;i++)cin >> t[i]; for(i=1;i<=n;i++)cin >> v[i]; for(i=1;i<=n;i++)cin >> d[i]; H=H*60; } void qhd() { for (int i=1;i<=n;i++) { res=f[i+1]; for (int j=5;j<=H;j=j+5) { if (j <= t[i]) { f[j]=f[j-5]+v[i]; v[i]-=d[i]; } else { f[j]=max(f[j-5]+v[i],f[j-5-t[i]]+res); if (f[j]==(f[j-5]+v[i])) v[i]-=d[i]; else res-=d[i+1]; } } } } main() { //freopen("CAUCA.INP","r",stdin); // freopen("CAUCA.OUT","w",stdout); doc(); qhd(); for (int i=5;i<=H;i=i+5) cout<<f[i]<<" "; cout<<endl << *max_element(f+1,f+H+1); }
Followed by
No followed post