1ac3wa1re,dp
  • 板块P1717 钓鱼
  • 楼主烛木
  • 当前回复0
  • 已保存回复0
  • 发布时间2020/9/12 11:35
  • 上次更新2023/11/5 13:22:14
查看原帖
1ac3wa1re,dp
366746
烛木楼主2020/9/12 11:35

1ac3wa1re 状态转移方程感觉没问题

#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int n,h,tot=1,htot,maxn,w[100][100],f[100],d[100],t[100];
int main()
{
	scanf("%d%d",&n,&h);
	h=h*60/5;
	for(int i=1;i<=n;i++)
	scanf("%d",&f[i]);
	for(int i=1;i<=n;i++)
	scanf("%d",&d[i]);
	for(int i=1;i<=n-1;i++)
	scanf("%d",&t[i]);
	for(int i=1;i<=n;i++)
	{
		for(int k=htot+1;k<=h;k++)
		{
			w[i][k]=max(w[i-1][k-t[i-1]-1]+f[i],w[i][k-1]+f[i]-tot*d[i]);
			if(w[i][k]==w[i][k-1])
			break;
			cout<<w[i][k]<<"   ";
			maxn=max(maxn,w[i][k]);
			if(w[i][k]==w[i][k-1]+f[i]-tot*d[i])
			tot++;
			else
			tot=1;
		}
		tot=0;
		htot+=t[i];
		cout<<endl;
	}
	cout<<maxn;
	return 0;
}
2020/9/12 11:35
加载中...