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 ...
随机推荐
- Codeforces Round #362
A - Pineapple Incident #pragma comment(linker, "/STACK:102c000000,102c000000") #include &l ...
- .NET中获取字符串的MD5码
C# 代码: 导入命名空间(需要在Web页面的代码页中引用) using System.Web.Security; 获取MD5码 string Password = FormsAuthenticati ...
- SDK "iphoneos" cannot be located
在MAC下,交叉编译libvlc出现的一些问题和解决方法.项目中使用了libvlc开源库.在执行编译脚本中,遇到一句xcrun --sdk iphoneos --show-sdk-path报错 mac ...
- 回车跳到下一个EDIT
1.按下方法procedure TForm2.Edit1KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);begin if Key ...
- iOS WebServiceFramework网络服务框架浅解
网络服务几乎是每一款成功APP的必备条件,打开你手机你会发现里面不用联网的应用数量十只手指可以数出来,就算是一些以独特技术切入市场的APP如美颜相机,都至少加入了分享功能.下面我先做下简单的回顾兼扫盲 ...
- Linux后台运行程序
Linux后台运行程序 最近写的程序需要部署到Linux服务器上,按照以前的方式,在运行后面增加&,程序会切换为后台运行.但因为Linux一般是通过ssh远程登录的,等到退出当前session ...
- linux下查看端口的占用情况
前提:首先你必须知道,端口不是独立存在的,它是依附于进程的.某个进程开启,那么它对应的端口就开启了,进程关闭,则该端口也就关闭了.下次若某个进程再次开启,则相应的端口也再次开启.而不要纯粹的理解为关闭 ...
- Light oj 1138 - Trailing Zeroes (III) (二分)
题目链接:http://lightoj.com/volume_showproblem.php?problem=1138 题目就是给你一个数表示N!结果后面的0的个数,然后让你求出最小的N. 我们可以知 ...
- UVALIVE 4970 最小权匹配
首先贴一下这道题的BNU地址,UVA地址自己找吧. http://acm.bnu.edu.cn/bnuoj/problem_show.php?pid=11852 题意:这道题的意思就是,给你N个棋子的 ...
- iOS开发-GCD和后台处理
一些生命周期函数的调用时间 打开应用时,调用 applicationWillEnterForeground: applicationDidBecomeActive: 按Home键,调用 applica ...