hdu——3127——WHUgirls
来源:互联网 发布:天基卫星通信网络 编辑:程序博客网 时间:2024/05/19 14:40
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.
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
Sample Input
1
2 4 4
2 2 2
3 3 9
Sample Output
9
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.
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
Sample Input
1
2 4 4
2 2 2
3 3 9
Sample Output
9
#include <iostream>#include <cstring>#include <algorithm>#include <cstdio>using namespace std;const int M=20;int dp[1005][1005];struct node{int x;int y;int v;}Node[M];int DP(int n,int x,int y){for(int i=1;i<=x;i++){for(int j=1;j<=y;j++){for(int k=0;k<n;k++){int x=Node[k].x;int y=Node[k].y;int v=Node[k].v;if(x<=i&&y<=j) dp[i][j]=max(dp[i][j],max(dp[i-x][y]+dp[i][j-y],dp[i-x][j]+dp[x][j-y])+v); swap(x,y); if(x<=i&&y<=j) dp[i][j]=max(dp[i][j],max(dp[i-x][y]+dp[i][j-y],dp[i-x][j]+dp[x][j-y])+v);}}}return dp[x][y];}int main(){int t;cin>>t;int n,x,y;while(t--){memset(dp,0,sizeof(dp)); cin>>n>>x>>y;for(int i=0;i<n;i++){cin>>Node[i].x>>Node[i].y>>Node[i].v;}cout<<DP(n,x,y)<<endl;}return 0;}
Sample Input
1
2 4 4
2 2 2
3 3 9
Sample Output
9
0 0
- hdu——3127——WHUgirls
- hdu 3127 WHUgirls
- hdu 3127 WHUgirls
- HDU 3127 WHUgirls
- HDU 3127 WHUgirls
- hdu 3127 WHUgirls
- 【HDU】 3127 WHUgirls
- HDU-3127 WHUgirls
- HDU 3127 WHUgirls 背包问题
- HDU 3127 WHUgirls (完全背包)
- HDU 3127 WHUgirls(完全背包)
- hdu-3127-WHUgirls解题报告
- HDU 3127 WHUgirls(完全背包)
- HDU OJ 3127 WHUgirls【DP之背包】
- hdu 3127 WHUgirls 二维完全背包
- HDU 3127 WHUgirls dp背包问题
- HDU OJ 3127 WHUgirls【DP之背包】
- 【DP】HDU 3127 WHUgirls 完全背包
- 快速排序
- 小流涓涓成江海,拙技点点构平台——细数OpenGL的异常
- css控制背景图片随div的大小而缩放
- hack web认证的常用方法
- 三大电信运营商TD-LTE 4G频段划分确定
- hdu——3127——WHUgirls
- jquery 插件地址链接
- 添加全局环境变量
- 紫杉醇
- Georgia and Bob(Nim游戏,只判断)
- Linux Shell编程一
- asdasdasd
- jtagice3固件升级方法
- Android UI - 带白边的自定义ImageView效果