Day9 - F - Monkey and Banana HDU - 1069
Input
Output对于每组测试数据,输出最大高度。格式:Case 第几组数据: maximum height = 最大高度Sample Input
2
6 8 10
5 5 5
7
1 1 1
2 2 2
3 3 3
4 4 4
5 5 5
6 6 6
7 7 7
5
31 41 59
26 53 58
97 93 23
84 62 64
33 83 27
0
Sample Output
Case 3: maximum height = 28
Case 4: maximum height = 342
const int maxm = ;
struct Node {
int x, y, z;
bool operator<(const Node &a) const {
return x < a.x || (x == a.x && y < a.y);
}
} Nodes[maxm];
int dp[maxm];
int main() {
ios::sync_with_stdio(false), cin.tie();
int n, t1, t2, t3, cnt, kase = ;
while(cin >> n && n) {
cnt = ;
for(int i = ; i <= n; ++i) {
cin >> t1 >> t2 >> t3;
Nodes[++cnt] = Node{t1, t2, t3};Nodes[++cnt] = Node{t2, t3, t1};Nodes[++cnt] = Node{t3, t1, t2};
Nodes[++cnt] = Node{t1, t3, t2};Nodes[++cnt] = Node{t2, t1, t3};Nodes[++cnt] = Node{t3, t2, t1};
}
sort(Nodes+, Nodes++cnt);
memset(dp, , sizeof(dp));
for(int i = ; i <= cnt; ++i) {
dp[i] = Nodes[i].z;
for(int j = ; j < i; ++j)
if(Nodes[i].x > Nodes[j].x && Nodes[i].y > Nodes[j].y)
dp[i] = max(dp[i], dp[j]+Nodes[i].z);
}
int ans = -;
for(int i = ; i <= cnt; ++i) ans = max(ans, dp[i]);
cout << "Case " << ++kase << ": maximum height = " << ans << "\n";
}
return ;
}
Day9 - F - Monkey and Banana HDU - 1069的更多相关文章
- (最大上升子序列)Monkey and Banana -- hdu -- 1069
http://acm.hdu.edu.cn/showproblem.php?pid=1069 Monkey and Banana Time Limit:1000MS Memory L ...
- (动态规划 最长有序子序列)Monkey and Banana --HDU --1069
链接: http://acm.hdu.edu.cn/showproblem.php?pid=1069 http://acm.hust.edu.cn/vjudge/contest/view.action ...
- Monkey and Banana HDU - 1069 有点像背包,又像最长上升序列
#include<iostream> #include<algorithm> #include<cstring> #include<vector> us ...
- HDU 1069 Monkey and Banana(二维偏序LIS的应用)
---恢复内容开始--- Monkey and Banana Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K ...
- HDU 1069 Monkey and Banana (DP)
Monkey and Banana Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u S ...
- HDU 1069 Monkey and Banana / ZOJ 1093 Monkey and Banana (最长路径)
HDU 1069 Monkey and Banana / ZOJ 1093 Monkey and Banana (最长路径) Description A group of researchers ar ...
- HDU 1069 Monkey and Banana(转换成LIS,做法很值得学习)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1069 Monkey and Banana Time Limit: 2000/1000 MS (Java ...
- hdu 1069 动规 Monkey and Banana
Monkey and Banana Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u ...
- HDU 1069—— Monkey and Banana——————【dp】
Monkey and Banana Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u S ...
随机推荐
- mqtt.mini.js 使用
html文件里直接调用 <!DOCTYPE html> <html lang="en"> <head> <meta charset=&qu ...
- StudentManagerSSM
web.xml StudentManagerSSM.rar <?xml version="1.0" encoding="UTF-8&quo ...
- 牛客跨年AK场-小sum的假期安排
链接:https://ac.nowcoder.com/acm/contest/3800/G来源:牛客网 题目描述 小 sun 非常喜欢放假,尤其是那种连在一起的长假,在放假的时候小 sun 会感到快乐 ...
- mcast_block_source函数
#include <errno.h> #include <sys/socket.h> #define SA struct sockaddr int mcast_block_so ...
- Tomcat访问控制及站点部署(以WAR包形式上传)!(重点)
访问控制 首先安装好jdk以及apache-tomcat并能访问tomcat网页 点击server status了解服务状态会报403的错误 第一步:修改user.xml配置文件 [root@loca ...
- Centos610无桌面安装Docker-安装
1.必备环境 设定docker源yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.rep ...
- vue通过get方法下载java服务器excel模板
vue方法 handleDownTemplateXls(fileName){ if(!fileName || typeof fileName != "string"){ fileN ...
- php cli 下 php.ini 配置
// 查看phpcli 模式下 扩展 php -m // 查看php cli 版本 php -v 查看命令行的ini路径,命令行下运行 php --ini Loaded Configuration F ...
- NSObject类的API介绍
这篇文章围绕的对象就是NSObject.h文件,对声明文件中的属性.方法进行必要的“翻译”. 该文件大致由两部分组成:NSObject协议和NSObject类. (一)NSObject协议 - (BO ...
- iOS中常用的手势
--前言 智能手机问世后的很长一段时间,各大手机厂商都在思考着智能手机应该怎么玩?也都在尝试着制定自己的一套操作方式.直到2007年乔布斯发布了iPhone手机,人们才认识到智能手机就应该这样玩. 真 ...