hdu Wooden Sticks
这题是暴力加贪心,算是一道水题吧!只要把l和w从小到大排个序就行了。。。
#include"iostream"
#include"stdio.h"
#include"string.h"
#include"cmath"
#include"algorithm"
#include"queue"
#define mx 10005
using namespace std;
struct node
{
int l,w; };
bool cmp(const node a,const node b)
{
if(a.l!=b.l) return a.l<b.l;
else return a.w<b.w;
}
node sticks[mx],temp;
int visited[mx]; bool judge(node a,node b)
{
if(a.l>=b.l&&a.w>=b.w) return true;
return false;
}
int main()
{
int t,n,i,j,minute;
cin>>t;
while(t--)
{ cin>>n;
minute=;
for(i=;i<n;i++)
{
cin>>sticks[i].l>>sticks[i].w;
} sort(sticks,sticks+n,cmp);
memset(visited,,sizeof(visited));
for(i=;i<n;i++)
{
if(!visited[i]){visited[i]=;minute++;}
else continue;
temp.l=sticks[i].l;temp.w=sticks[i].w;
for(j=i+;j<n;j++)
{
if(!visited[j]&&judge(sticks[j],temp))
{
visited[j]=;temp.l=sticks[j].l;temp.w=sticks[j].w;
}
}
}
cout<<minute<<endl;
}
return ;
}
hdu Wooden Sticks的更多相关文章
- HDU 1005 Wooden Sticks
http://acm.hdu.edu.cn/showproblem.php?pid=1051 Problem Description There is a pile of n wooden stick ...
- HDU ACM 1051/ POJ 1065 Wooden Sticks
Wooden Sticks Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tot ...
- HDU 1051 Wooden Sticks (贪心)
Wooden Sticks Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) To ...
- HDU 1051:Wooden Sticks
Wooden Sticks Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) To ...
- HDU 1051 Wooden Sticks 贪心||DP
Wooden Sticks Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tot ...
- HDU - 1051 Wooden Sticks 贪心 动态规划
Wooden Sticks Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- hdu 1051:Wooden Sticks(水题,贪心)
Wooden Sticks Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tot ...
- HDU 1051: Wooden Sticks(贪心)
Wooden Sticks Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) To ...
- HDOJ 1051. Wooden Sticks 贪心 结构体排序
Wooden Sticks Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) To ...
随机推荐
- Android 中的AsyncTask
在后台下载图片,下载完成后更新UI是一个很常见的需求.在没有AsyncTask类之前,我们需要写许多thread和Handler的代码去实现这个功能,有了AsyncTask,一切变得简单了.下面摘抄谷 ...
- Android 中PendingIntent---附带解决AlarmManager重复加入问题
最近在程序中使用到了notification功能,自然,就涉及到了PendingIntent,下面总结下. 1 什么是PendingIntent A description of an Intent ...
- Java与数据库类型对照表
数据库类型 Java类型 INTEGER int or java.lang.Integer BIGINT long or java.lang.Long SMALLINT short o ...
- eclipse原文件编码GBK-UTF8
菜单Window-Preferences-General-Workspace,在右侧面板的Text file encoding选项中选择Other:UTF-8 上一步如果不起作用,可以尝试设置下: W ...
- 解决 internet connection sharing 启动不了
1.确认Windows Firewall服务是否启动(有异常可参考下面) a.打开注册表,找到HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\ ...
- Emblog 备忘
emblog换后台:(如admin-->xx) 1.xx目录下的globals.php打开找到替换admin(1) 2.www目录下的t\index.php 中找到替换admin(1) 3.ww ...
- ASP.Net和新对象之context.Server
描述 Server是一个HttpServerUtility类型的对象,不是一个类名 1.获取服务器上的绝对路径文件名tring ss = context.Server.MapPath("~/ ...
- CentOS下配置Hadoop集群:java.net.NoRouteToHostException: No route to host问题的解决
我用的是hadoop 1.2.1 遇到的问题是: hadoop中datanode无法启动,报Caused by: java.net.NoRouteToHostException: No route t ...
- CentOS 6.5 下安装 Kibana5
1. 导入Elastic PGP Key 执行命令 rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch 2. 安装Kiban ...
- WMI
https://wiki.jenkins-ci.org/display/JENKINS/Windows+slaves+fail+to+start+via+DCOM#Windowsslavesfailt ...