随笔分类 - DP-背包
摘要:普通多重背包 外层枚举哪个包,中层枚举容量,内存枚举数量 for(i=1; i<=n; ++i) for(j=m; j>=0; --j) for(k=1; k*w[i]<=j && j<=s[i]; ++k) f[j]=max(f[j], f[j-k*w[i]]+k*v[i]); 二进制优化 相当于
阅读全文
摘要:题目链接 题目 原题来自:POI 2005 Byteotian Bit Bank (BBB) 拥有一套先进的货币系统,这个系统一共有 种面值的硬币,面值分别为 。但是每种硬币有数量限制,现在我们想要凑出面值 ,求最少要用多少个
阅读全文
摘要:题目链接 题目 There is a square matrix n × n, consisting of non-negative integer numbers. You should find such a way on it that starts in the upper left cel
阅读全文
摘要:题目链接 题目 You are given a sequence of numbers a1, a2, ..., an, and a number m. Check if it is possible to choose a non-empty subsequence aij such that t
阅读全文
摘要:题目链接 题目 Your company has just constructed a new skyscraper, but you just noticed a terrible problem: there is only space to put one game room on each
阅读全文
摘要:题目链接 看到什么价值的什么喜爱度的明显是背包。 然而题目还要考虑小明的感受,所以弄个二维费用背包。 设 为前 道菜,用 元,且小明的喜爱程度为 时小红的最大喜爱度。 如果不选,则 \(dp(i, j, k)=dp(i-1, j,
阅读全文