为人民服务

X-louyicheng 2022-08-10 14:49:53 21 返回题目

#include<bits/stdc++.h>
using namespace std;
int v,n;
int f[200+10];
struct node{
	int c,w,p;
};
node a[40];
int main(){
	cin>>v>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i].c>>a[i].w>>a[i].p;
		if(a[i].p==0){
			a[i].p=200;
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=v;j>=a[i].c;j--){
			for(int k=1;k<=a[i].p;k++){
				if(j>=k*a[i].c) f[j]=max(f[j],f[j-k*a[i].c]+k*a[i].w);
			}
		}
	}
	cout<<f[v];
	return 0;
}
{{ vote && vote.total.up }}

共 1 条回复

X-louhaocheng

emm emm emm emm