nyoj236 心急的C小加
来源:互联网 发布:m audio 610驱动 mac 编辑:程序博客网 时间:2024/05/21 17:34
原题: http://acm.nyist.net/JudgeOnline/problem.php?pid=236
同样题目poj1065 Wooden Sticks http://poj.org/problem?id=1065
//将木棍先按l由小到大排序,再按w排序,最后遍历即可.#include<iostream>#include<cstdio>#include<algorithm>using namespace std;struct M{int l;int w;}m[5010];int cmp(M a,M b){if(a.l!=b.l){return a.l<b.l;}else{return a.w<b.w;}}int main(){int t;scanf("%d",&t);while(t--){int i,n;scanf("%d",&n);for(i=0;i<n;i++){scanf("%d %d",&m[i].l,&m[i].w);}sort(m,m+n,cmp);int ans=1;int l=m[0].l;int w=m[0].w;while(true){for(i=1;i<n;i++){if(m[i].l==-1)continue;if(m[i].l>=l && m[i].w>= w){l=m[i].l;w=m[i].w;m[i].l=-1;}}//l=-1;for(i=1;i<n;i++){if(m[i].l!=-1){l=m[i].l;w=m[i].w;break;}}if(i==n)break;ans++;}printf("%d\n",ans);}return 0;} //AC
阅读全文
0 0
- NYOJ236 心急的C小加 【贪心】
- nyoj236 心急的C小加 【贪心】
- nyoj236心急的c小加
- nyoj236心急的C小加
- nyoj236心急的C小加
- nyoj236 心急的C小加
- nyoj236 心急的C小加
- NYOJ236心急的c小加
- NYOJ236 心急的C小加
- nyoj236 心急的C小加
- NYOJ236,心急的C小加(偏序集 Dilworth 定理)
- NYOJ236 心急的C小加&NYOJ 16 矩形嵌套
- NYOJ236. 心急的C小加(排序+贪心)
- uvaoj 2322 Wooden Sticks(nyoj236 心急的C小加)
- 心急的C小加
- 心急的C小加
- 心急的C小加
- 心急的C小加
- atitit 用什么样的维度看问题.docx 如何了解 看待xxx
- 分析Android中Handle机制
- 计算机领域资讯(二)
- 进程与线程简单概述
- mysql 总结
- nyoj236 心急的C小加
- CodeForces
- atitit 项目团队管理之道.docx
- Android五大布局简介
- sdram学习笔记
- ffmpeg音视频基础学习
- Docker Toolbox
- 常用工具网站
- UVA-11988 Broken Keyboard (a.k.a. Beiju Text)