博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
UESTC 电子科大专题训练 DP-D
阅读量:5319 次
发布时间:2019-06-14

本文共 964 字,大约阅读时间需要 3 分钟。

题意:中文题

思路:混合背包

AC代码:

#include "iostream"#include "string.h"#include "stack"#include "queue"#include "string"#include "vector"#include "set"#include "map"#include "algorithm"#include "stdio.h"#include "math.h"#define ll long long#define bug(x) cout<
<<" "<<"UUUUU"<
=cost; i--) dp[i]=max(dp[i],dp[i-cost]+weight);}void complete(int cost, int weight){ for(int i=cost; i<=vol; i++) dp[i]=max(dp[i],dp[i-cost]+weight);}void mutilpack(int cost,int weight,int counts){ if(counts*cost>vol){ complete(cost,weight); return; } for(int i=1; i
>n>>vol; for(int i=1; i<=n; ++i){ cin>>t[i]>>a[i]>>b[i]; if(t[i]==2) t[i]=1; else if(t[i]==1) t[i]=-1; } for(int i=1; i<=n; ++i){ if(t[i]==-1) complete(b[i],a[i]); else mutilpack(b[i],a[i],t[i]); } cout<
<

 

转载于:https://www.cnblogs.com/max88888888/p/7202434.html

你可能感兴趣的文章