题目:
In the future several years, you will surely remember that you once participated in a special China Collegiate Programming Contest. Due to COVID-19, all parties had paid a lot of effort to eventually hold a rare online programming contest. As a problem writer, I would also like to express my sincere gratitude to the organizing committee, all the contestants and others who have worked hard in this process. I also sincerely wish you good results in this special contest and a special and sweat memory in the future.
Maybe several years later, you may recall that …
Once there was a mobile game, where there was a virtual currency called coupon that could only be purchased by RMB. Kelo found that relying on his liver alone cannot make him stronger, so he decided to purchase some coupons. When he opened the recharge page, he found that this game had seven recharge columns, and was holding an activity called “First Recharge Reward”. If it was the first time a recharge column was chosen, some additional coupons would be given to the player as a reward. A player might receive several rewards if he chose several different recharge columns. A column could be chosen for arbitrary times, but there would be no additional reward except for the first time it was chosen. Here is a table describing the price, amount of coupons in normal case and additional first recharge rewards of each column.
[Math Processing Error]
Kelo had recently earned [Math Processing Error] yuan by writing problems for China Collegiate Programming Contest. He decided to recharge all these [Math Processing Error] yuan to the game, and hoped to get as many coupons as possible with these hard-earned money.
Input
The only line contains an only integer [Math Processing Error] ([Math Processing Error]).
Output
Print the maximum amount of coupons Kelo might get.
Examples
Input
100
Output
1084
Input
198
Output
2108
题解:
01背包和完全背包的混合背包
#include <bits/stdc++.h>
using namespace std;
const int N=2005;
int f[N];
struct node {int k,v,w;
};
vector<node> e;
int main()
{int m;cin>>m;e.push_back({-1,1,18});e.push_back({-1,6,60+18});e.push_back({-1,28,280+28});e.push_back({-1,88,880+58});e.push_back({-1,198,1980+128});e.push_back({-1,328,3280+198});e.push_back({-1,648,6480+388});e.push_back({1,1,10});e.push_back({1,6,60});e.push_back({1,28,280});e.push_back({1,88,880});e.push_back({1,198,1980});e.push_back({1,328,3280});e.push_back({1,648,6480});for(int i=0;i<14;i++){if(e[i].k==-1){for(int j=m;j>=e[i].v;j--){f[j]=max(f[j],f[j-e[i].v]+e[i].w);}}else{for(int j=e[i].v;j<=m;j++){f[j]=max(f[j],f[j-e[i].v]+e[i].w);}}}cout<<f[m]<<endl;return 0;
}