95分求助!!
查看原帖
95分求助!!
951987
litchi36楼主2023/11/11 13:45

题目传送门

#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int t,n,f[60][100010],w[60],v[60];
struct node{
	int a,b,c;
}d[100];
bool cmp(node x,node y){
	return x.c*y.b<y.c*x.b;
}
int main() {
	cin>>t>>n;
	for(int i=1;i<=n;i++)cin>>d[i].a;
	for(int i=1;i<=n;i++)cin>>d[i].b;
	for(int i=1;i<=n;i++)cin>>d[i].c;
	sort(d+1,d+n+1,cmp);
	for(int i=1;i<=n;i++){
		for(int j=0;j<=t;j++){
				f[i][j]=f[i-1][j];
				if(j>=d[i].c){
					f[i][j]=max(f[i][j],f[i-1][j-d[i].c]+d[i].a-j*d[i].b);
				
			}
		}
	}
	int res=0;
	for(int i=0;i<=t;i++){
		res=max(res,f[n][i]);
	}
	cout<<res;
    return 0;
}
2023/11/11 13:45
加载中...