ACM: 动态规划题 poj 2923
来源:互联网 发布:win7如何安装linux系统 编辑:程序博客网 时间:2024/06/09 17:56
Emma and Eric are moving to their new house they bought afterreturning from their honeymoon. Fortunately, they have a fewfriends helping them relocate. To move the furniture, they onlyhave two compact cars, which complicates everything a bit. Sincethe furniture does not fit into the cars, Eric wants to put them ontop of the cars. However, both cars only support a certain weighton their roof, so they will have to do several trips to transporteverything. The schedule for the move is planed like this:
- At their old place, they will put furniture on both cars.
- Then, they will drive to their new place with the two cars andcarry the furniture upstairs.
- Finally, everybody will return to their old place and theprocess continues until everything is moved to the new place.
Note, that the group is always staying together so that they canhave more fun and nobody feels lonely. Since the distance betweenthe houses is quite large, Eric wants to make as few trips aspossible.
Given the weights wi of each individual pieceof furniture and the capacities C1 andC2 of the two cars, how many trips to the newhouse does the party have to make to move all the furniture? If acar has capacity C, the sum of the weights of all thefurniture it loads for one trip can be at most C.
Input
The first line contains thenumber of scenarios. Each scenario consists of one line containingthree numbers n, C1 andC2. C1 and C2are the capacities of the cars (1 ≤ Ci ≤ 100) andn is the number of pieces of furniture (1 ≤ n ≤ 10).The following line will contain n integersw1, …, wn, the weights of thefurniture (1 ≤ wi ≤ 100). It is guaranteed thateach piece of furniture can be loaded by at least one of the twocars.
Output
The output for everyscenario begins with a line containing “Scenario#i:”, where i is the number of thescenario starting at 1. Then print a single line with the number oftrips to the new house they have to make to move all the furniture.Terminate each scenario with a blank line.
Sample Input
2
6 12 13
3 9 13 3 10 11
7 1 100
1 2 33 50 50 67 98
Sample Output
Scenario #1:
2
Scenario #2:
3
题意: Emma and Eric 蜜月回来, 他们有2部车载重量分别为c1,c2.
解题思路: (这题没有思路, 从网上学会的)
代码:
#include <cstdio>
#include <iostream>
#include <cstring>
using namespace std;
#define MAX 11
const int INF = (1<<29);
int n, c1, c2;
int w[MAX], s;
int dp[1<<MAX], num,flag[1<<MAX];
inline int min(int a, int b)
{
}
bool judge(int x)
{
}
int DP()
{
}
int main()
{
//
}
- ACM: 动态规划题 poj 2923
- ACM: 简单动态规划题 poj 2955
- ACM: 动态规划题 poj 2241
- ACM: 动态规划题 poj 1054
- ACM: 动态规划题 poj 2948
- ACM: 动态规划题 poj 1925
- ACM: 动态规划题 poj 3034
- ACM: 动态规划题 poj 2411
- ACM: 动态规划题 poj 1947
- ACM: 动态规划题 poj 2486
- ACM: 动态规划题 poj 3140
- ACM: 动态规划题 poj 3659
- ACM: dp动态规划题(难) poj 3267 …
- ACM: dp题(动态规划) poj 2151 (d…
- ACM: 树状DP 动态规划题 poj 1463 …
- ACM: 动态规划题 poj 2057 树状DP
- ACM:动态规划题 poj 1015
- ACM: 动态规划题 poj&nb…
- ACM: 动态规划题 poj 3211 背包变…
- (OK)(OK) Fedora23——NS3(MANETs)——Docker(busybox)——genymotion(android)——All is OK
- ACM: 动态规划题 poj&nb…
- ACM: 动态规划题 poj 3093 0-1背包
- ACM: 动态规划题 poj&nb…
- ACM: 动态规划题 poj 2923
- 兴趣学习: opencv -- 视频读写, 鼠…
- 兴趣学习: opencv 实现画图程序
- ACM: 图论题 poj 3…
- ACM: 动态规划题 poj&nb…
- ACM: 博弈题 poj 1143 状态压缩
- ACM: 图论题 poj 2186 强连通分量
- ACM: 图论题 poj 3352 双连通题
- ACM: 图论题 poj 3177 同 3352