hdu 1051_贪心
来源:互联网 发布:苹果来电拦截软件 编辑:程序博客网 时间:2024/05/16 15:16
http://acm.hdu.edu.cn/showproblem.php?pid=1051
#include<stdio.h>#include<algorithm>using namespace std;const int maxn = 5010;struct stick{ int length; int weight; bool vis;};bool cmp(stick s1, stick s2){ if(s1.length < s2.length) return true; else if(s1.length == s2.length) return s1.weight < s2.weight; return false;}int n;stick s[maxn]; int main(){ int test; scanf("%d", &test); while(test--) { scanf("%d", &n); for(int i = 0; i < n; i++) { scanf("%d%d", &s[i].length, &s[i].weight); s[i].vis = false; } sort(s, s+n, cmp); int ans = 0; for(int i = 0; i < n; i++) { if(!s[i].vis) { s[i].vis = true; ++ans; int weight = s[i].weight; for(int j = i+1; j < n; j++) if(!s[j].vis && s[j].weight >= weight) { s[j].vis = true; weight = s[j].weight; } } } printf("%d\n", ans); } return 0;}
0 0
- hdu 1051_贪心
- hdu 2037_贪心
- hdu 1050_贪心
- hdu 3177_贪心
- HDU_1050 1051 [贪心]_水
- HDU 1051 贪心算法
- [HDU-1051] 贪心
- hdu 1051 贪心
- HDU 1051(贪心)
- 贪心问题 HDU 1051
- hdu 1051(贪心算法)
- hdu 1051 贪心
- HDU 1051(贪心)
- hdu 1051 贪心
- HDU 1051(贪心)
- HDU 1052 田忌赛马 (贪心_好题)
- hdu 1051 Wooden Sticks 贪心
- hdu 1051 Wooden Sticks 贪心
- HDOJ1002 A + B Problem II
- [科研日志] EWH(1)
- ssh框架的二级缓存注释配置
- VJ -链表训练--要记住啊!插入是:r->next=pa->next; pa->next=r;不能再错啦!!
- ORACLE 对CPU的限制
- hdu 1051_贪心
- 条款6:若不想使用编译器自动生成的函数,就该明确拒绝
- QT中的pro文件的编写 (转)
- 数据结构之--图
- hdoj 2031 进制转换
- strstr函数
- 转盘抽奖
- 进程同步之信号量机制(pv操作)及三个经典同步问题
- Tomcat优化及压力测试实例