hdu1051 Wooden Sticks
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1051
大意:求最少升序序列的个数。
#include <cstdio>
#include <cstring>
#include <algorithm>
#define N 5000 + 5
using namespace std;
struct node {
int x, y;
bool operator < (const node& t) const {
return (x < t.x) || (x == t.x && y < t.y);
}
} f[N];
bool mark[N];
int main()
{
int T, n, tw, ans, i, j;
scanf("%d", &T);
while (T--) {
scanf("%d", &n);
for (i = 0; i < n; i++) scanf("%d%d", &f[i].x, &f[i].y);
sort(f, f + n);
memset(mark, false, sizeof(mark));
ans = 0;
for (i = 0; i < n; i++)
if (!mark[i]) {
tw = f[i].y;
mark[i] = true;
ans++;
for (j = i + 1; j < n; j++)
if (!mark[j] && f[j].y >= tw) {
tw = f[j].y;
mark[j] = true;
}
}
printf("%d\n", ans);
}
return 0;
}
hdu1051 Wooden Sticks的更多相关文章
- HDU1051 Wooden Sticks 【贪婪】
Wooden Sticks Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) To ...
- Hdu1051 Wooden Sticks 2017-03-11 23:30 62人阅读 评论(0) 收藏
Wooden Sticks Problem Description There is a pile of n wooden sticks. The length and weight of each ...
- hdu1051 Wooden Sticks(贪心+排序,逻辑)
Wooden Sticks Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tot ...
- HDU1051:Wooden Sticks
Problem Description There is a pile of n wooden sticks. The length and weight of each stick are know ...
- Wooden Sticks(hdu1051)
Wooden Sticks Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Submi ...
- HDU-1051/POJ-1065 Wooden sticks 木棍子(动态规划 LIS 线型动归)
嘤嘤嘤,实习半年多的小蒟蒻的第一篇博客(题解) 英文的: There is a pile of n wooden sticks. The length and weight of each stick ...
- HDOJ 1051. Wooden Sticks 贪心 结构体排序
Wooden Sticks Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) To ...
- POJ 1065 Wooden Sticks
Wooden Sticks Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 16262 Accepted: 6748 Descri ...
- HDU ACM 1051/ POJ 1065 Wooden Sticks
Wooden Sticks Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tot ...
随机推荐
- 重新安装Photoshop CS6以后启动软件出现Licensing for this product has expired
当我们卸载试用版本Photoshop CS6并且重新安装,出现Licensing for this product has expired,并且无法打开软件,这是由于证书过期导致的,解决办法是将计算机 ...
- 通过库函数API和C代码中嵌入汇编代码剖析系统调用的工作机制
作者:吴乐 山东师范大学<Linux内核分析>MOOC课程http://mooc.study.163.com/course/USTC-1000029000 本次实验的主要内容就是分别采用A ...
- Ajax异步请求PHP数据
来源:http://www.ido321.com/1138.html 接到了老师的一个作业,实现的布局如图: 如果输入了科室ID,科室名字只显示与ID对应的,若没有输入,则显示全部,然后根据I科室名字 ...
- UNIX系统文件
密码文件 密码文件又称用户数据库,一般为/etc/passwd,对应的结构为struct passwd,该文件内容大体如下: 描述 passwd字段 用户名 char* pw_name 加密密码 ch ...
- A题进行时--浙大PAT 1021-1030
1021: #include<stdio.h> #include<string.h> #include<vector> #include<queue> ...
- Codevs No.1163 访问艺术馆
2016-05-31 20:48:47 题目链接: 访问艺术馆 (Codevs No.1163) 题目大意: 一个贼要在一个二叉树结构的艺术馆中偷画,画都处于叶子节点处,偷画和经过走廊都需要时间,求在 ...
- RabbitMQ C# 例子 -摘自网络
//刚刚接触,如有不对还望不吝指正 public static void StartUp() { #region 前期准备工作 ConnectionFactory factory = new Conn ...
- redis的lists类型
List是一个链表结构 , 主要功能是push . pop .获取一个范围的所有值等等 , 操作中key理解为链表的名字 . redis 的 list类型其实就是一个每个子元素都是string类型的双 ...
- HiveContext VS SQLContext
There are two ways to create context in Spark SQL: SqlContext:scala> import org.apache.spark.sql. ...
- HDU 5791 Two (DP)
Two 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5791 Description Alice gets two sequences A and ...