HDU3552(贪心)
来源:互联网 发布:国家统计局网站数据库 编辑:程序博客网 时间:2024/04/29 05:34
题目是将一系列点对(a,b)分成两个集合,使得A集合的最大a+B集合的最大数b得和最小。
思路:http://blog.csdn.net/dgq8211/article/details/7748078
我真是太差了,担心担心担心...醒来继续努力。
/***********************************************************> OS : Linux 3.13.0-24-generic (Mint-17)> Author : yaolong> Mail : dengyaolong@yeah.net> Time : 2014年10月15日 星期三 11时10分06秒 **********************************************************/#include <iostream>#include <cstdio>#include <string>#include <cstring>#include <algorithm>using namespace std;pair<int, int> a[100001];int main(){ int cas, n; scanf ( "%d", &cas ); int ind = 0; while ( cas-- ) { scanf ( "%d", &n ); for ( int i = 1; i <= n; i++ ) { scanf ( "%d%d", &a[i].first, &a[i].second ); } sort ( a + 1, a + n + 1 ); a[0].first = 0; a[n + 1].second = 0; int ans = 1 << 30, B = 0; for ( int i = n; i >= 0; i-- ) { B = max ( B, a[i + 1].second ); ans = min ( ans, a[i].first + B ); } printf ( "Case %d: %d\n", ++ind, ans ); } return 0;}
0 0
- HDU3552(贪心)
- hdu3552(排序)
- 贪心!
- 贪心~
- 贪心
- 贪心
- 贪心
- 贪心
- 贪心
- 贪心
- 贪心
- 贪心
- 贪心
- 贪心
- 贪心
- 贪心
- 贪心
- 贪心
- IOS 开发中判断字符串是否为空字符的方法
- 在Linux下设定 MATLAB 的默认工作路径
- java 多继承
- iOS开发:加载、滑动翻阅大量图片解决方案
- resgen.exe 已退出 代码为 1073741701的错误的解决办法
- HDU3552(贪心)
- soa---java 多线程的---锁
- 单独测试某个activity
- 存储过程的好处和一些注意事项!
- linux ab 下的 压力测试
- VMware虚拟机CentOS的网络设置
- 对大学的认识
- 关联规则基本方法
- iOS7 UINavigationBar设置白色但是出现半透明解决方法