题目描述: https://www.luogu.org/problem/P5662?contestId=24102
完全背包问题,因数据量不大,可以先用map二维数组把输入全存下来。
对某一天来说,把数据处理成完全背包问题:其中,买某一个物品需多少钱,相当于背包问题中的weigth;
明天该物品价钱-今天当前物品价钱就相当于是价值value。动态规划求出在当前手里有的M金币下,明天都卖掉最多能赚多少,随后M=M+dp[M]。
/*
T未来天数 N纪念品数量 M现在拥有的金币数量
*/
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;
int map[105][105];
struct node{
int w,v;
//weigth记录买当前物品需花掉的钱,value记录能赚多少钱 (下一天的价格-今天的价格)
}point;
int solve(vector<node>& v,int M){
int dp[10005]={0};
int len=v