题意 n个有体积的物品,问选取一些物品,且不能再继续选有多少方法? n<=1000 题解 以前的考试题.当时是A了,但发现是数据水,POJ上WA了. 把体积从小到大排序枚举没选的物品中体积最小的. 假设枚举到i,那么1到i-1一定都选.可选的空间为[m-sum[i-1]+1,m] 然后对于后面的数跑DP的到f[i][j]前i个数空间恰好为j时的方案: 贡献为可选空间的方案. 一个优化是倒着枚举i,这样在求f[i][j]时所花费的时间会大大减少. #include<iostream> #i…
题目 Description One of the more popular activities in San Antonio is to enjoy margaritas in the park along the river know as the River Walk. Margaritas may be purchased at many establishments along the River Walk from fancy hotels toJoe’s Taco and Mar…
Description One of the more popular activities in San Antonio is to enjoy margaritas in the park along the river know as the River Walk. Margaritas may be purchased at many establishments along the River Walk from fancy hotels to Joe’s Taco and Marga…
Description One of the more popular activities in San Antonio is to enjoy margaritas in the park along the river know as the River Walk. Margaritas may be purchased at many establishments along the River Walk from fancy hotels to Joe's Taco and Marga…
题目链接: id=1636">POJ 1636 Prison rearrangement Prison rearrangement Time Limit: 3000MS   Memory Limit: 10000K Total Submissions: 2194   Accepted: 984 Description In order to lower the risk of riots and escape attempts, the boards of two nearby priso…
Description There is a worker who may lack the motivation to perform at his peak level of efficiency because he is lazy. He wants to minimize the amount of work he does (he is Lazy, but he is subject to a constraint that he must be busy when there is…
题意:有多种颜色的衣服,由两个人合作来洗,必须洗完一种颜色才能洗下一种,求需要多少时间能洗完. 思路:将衣服按颜色分类,对每种颜色进行01背包,容量上限是该种颜色衣服全部洗完的耗时长一半,其实就是在最公平地平分工作量.因为一个先洗完就得等到另一人洗完.最后把洗完每种颜色的时长加起来返回.注:poj不允许用map,不然更省事,根据string和int做个哈希映射. //#include <bits/stdc++.h> #include <iostream> #include <…
2287: [POJ Challenge]消失之物 Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 657  Solved: 382[Submit][Status][Discuss] Description ftiasch 有 N 个物品, 体积分别是 W1, W2, ..., WN. 由于她的疏忽, 第 i 个物品丢失了. “要使用剩下的 N - 1 物品装满容积为 x 的背包,有几种方法呢?” -- 这是经典的问题了.她把答案记为 Count(…
题目链接:http://poj.org/problem?id=1015 题目: 题解: 我们考虑设计DP状态(因为这很显然是一个完全背包问题不是吗?) dp[j][k]表示在外层循环到i时,选了j个人,此时辩方总分和控方总分差值为k的时,辩方和控方的总分的和的最大值 dp[j][k+a[i]-b[i]] = max (dp[j][k + a[i] - b[i]] , dp[j][k] + a[i] + b[i]) 因为是完全背包,所以我们需要写一个search函数判断当前转移的状态是否已经选过了…
POJ :http://poj.org/problem?id=1384 ZOJ:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2014 题目大意: 给定一个猪的存钱罐,它的初始重量和装满的重量,给你n种货币(包括它们的重量和价值),要求求最坏情况下装满这个猪所能获得的钱 依旧是完全背包的问题. 只不过一开始只有什么都不装有合法解,其他均为无穷大,即一开始dp[0]=0 然后改为求min而不是max(题目要求最坏情况下)…