HDU 3127 WHUgirls(完全背包)
来源:互联网 发布:知乎live结束后能看吗 编辑:程序博客网 时间:2024/05/19 15:44
WHUgirls
Time Limit : 3000/2000ms (Java/Other) Memory Limit : 131072/131072K (Java/Other)
Total Submission(s) : 31 Accepted Submission(s) : 13
Font: Times New Roman | Verdana | Georgia
Font Size: ← →
Problem Description
There are many pretty girls in Wuhan University, and as we know, every girl loves pretty clothes, so do they. One day some of them got a huge rectangular cloth and they want to cut it into small rectangular pieces to make scarves. But different girls like different style, and they voted each style a price wrote down on a list. They have a machine which can cut one cloth into exactly two smaller rectangular pieces horizontally or vertically, and ask you to use this machine to cut the original huge cloth into pieces appeared in the list. Girls wish to get the highest profit from the small pieces after cutting, so you need to find out a best cutting strategy. You are free to make as many scarves of a given style as you wish, or none if desired. Of course, the girls do not require you to use all the cloth.
Input
The first line of input consists of an integer T, indicating the number of test cases.
The first line of each case consists of three integers N, X, Y, N indicating there are N kinds of rectangular that you can cut in and made to scarves; X, Y indicating the dimension of the original cloth. The next N lines, each line consists of two integers, xi, yi, ci, indicating the dimension and the price of the ith rectangular piece cloth you can cut in.
The first line of each case consists of three integers N, X, Y, N indicating there are N kinds of rectangular that you can cut in and made to scarves; X, Y indicating the dimension of the original cloth. The next N lines, each line consists of two integers, xi, yi, ci, indicating the dimension and the price of the ith rectangular piece cloth you can cut in.
Output
Output the maximum sum of prices that you can get on a single line for each case.
Constrains
0 < T <= 20
0 <= N <= 10; 0 < X, Y <= 1000
0 < xi <= X; 0 < yi <= Y; 0 <= ci <= 1000
Constrains
0 < T <= 20
0 <= N <= 10; 0 < X, Y <= 1000
0 < xi <= X; 0 < yi <= Y; 0 <= ci <= 1000
Sample Input
12 4 42 2 23 3 9
Sample Output
9
Source
2009 Asia Wuhan Regional Contest Online
point:
看 http://blog.csdn.net/u013480600/article/details/40512311
#include <iostream>#include <stdio.h>#include <string.h>#include <algorithm>using namespace std;#define ll long longint dp[1011][1011];int xi[11];int yi[11];int val[11];int main(){ int T; scanf("%d",&T); while(T--) { memset(dp,0,sizeof dp); int n,X,Y; scanf("%d %d %d",&n,&X,&Y); for(int i=1; i<=n; i++) { scanf("%d %d %d",&xi[i],&yi[i],&val[i]); } for(int y=1; y<=Y; y++) { for(int x=1; x<=X; x++) { for(int i=1; i<=n; i++) { if(xi[i]<=x&&yi[i]<=y) dp[x][y]=max(dp[x][y],max(dp[xi[i]][y-yi[i]]+dp[x-xi[i]][y],dp[x-xi[i]][yi[i]]+dp[x][y-yi[i]])+val[i]); if(xi[i]<=y&&yi[i]<=x) dp[x][y]=max(dp[x][y],max(dp[yi[i]][y-xi[i]]+dp[x-yi[i]][y],dp[x-yi[i]][xi[i]]+dp[x][y-xi[i]])+val[i]); } } } printf("%d\n",dp[X][Y]); } return 0;}
0 0
- HDU 3127 WHUgirls (完全背包)
- HDU 3127 WHUgirls(完全背包)
- HDU 3127 WHUgirls(完全背包)
- hdu 3127 WHUgirls 二维完全背包
- 【DP】HDU 3127 WHUgirls 完全背包
- HDU 3127 WHUgirls (线性dp 完全背包)
- hdu 3127 WHUgirls(完全背包)
- 【HDU 3127】WHUgirls(二维完全背包)
- HDU-3127-WHUgirls(完全背包)
- HDU 3127 WHUgirls 背包问题
- HDOJ 题目3127 WHUgirls(完全背包)
- HDU3127:WHUgirls(完全背包)
- HDU OJ 3127 WHUgirls【DP之背包】
- HDU 3127 WHUgirls dp背包问题
- HDU OJ 3127 WHUgirls【DP之背包】
- hdu 3127 WHUgirls(二维背包)
- HDU 3127 WHUgirls(二维背包)
- HDU 3127 WHUgirls(二维背包)
- Cocos2d-X多线程
- Linux中启动Steam报错libGL error的解决办法
- 线性表学习
- 长度小于3的正整数
- am335x 700根文件加载过程分析
- HDU 3127 WHUgirls(完全背包)
- JSP中的标准动作
- 正则表达式的JS验证
- Java 通过Request请求获取IP地址
- spring框架入门
- 数字校验的正则表达式
- VS2013的LINK2005问题解决方案(仅限由第三方库造成的问题)+ 附LNK2038
- 队列学习(2)
- Android编程心得-使用Application类保存应用的全局数据