bzoj 1669: [Usaco2006 Oct]Hungry Cows饥饿的奶牛
1669: [Usaco2006 Oct]Hungry Cows饥饿的奶牛
Time Limit: 5 Sec Memory Limit: 64 MB
Submit: 990 Solved: 647
[Submit][Status][Discuss]
Description
Input
Output
Sample Input
Sample Output
裸的最长递增子序列
用nlogn的方法
#include<stdio.h>
#include<string.h>
int a[100005], best[100005], ans[100005], len;
int Bsech(int x)
{int l, r, m;l = 0, r = len;while(l<r){m = l+(r-l)/2;if(best[m]>=x) r = m;elsel = m+1;}return l;
}
int main(void)
{int n, i, pos;while(scanf("%d", &n)!=EOF){for(i=1;i<=n;i++)scanf("%d", &a[i]);len = 1;best[1] = a[1], ans[1] = 1;for(i=2;i<=n;i++){if(a[i]>best[len])best[++len] = a[i], ans[i] = len;else{ pos = Bsech(a[i]);best[pos] = a[i];}}printf("%d\n", len);}return 0;
}
bzoj 1669: [Usaco2006 Oct]Hungry Cows饥饿的奶牛相关推荐
- [BZOJ1669][Usaco2006 Oct]Hungry Cows饥饿的奶牛
1669: [Usaco2006 Oct]Hungry Cows饥饿的奶牛 Time Limit: 5 Sec Memory Limit: 64 MB Submit: 1000 Solved: 6 ...
- bzoj1669[Usaco2006 Oct]Hungry Cows饥饿的奶牛*
bzoj1669[Usaco2006 Oct]Hungry Cows饥饿的奶牛 题意: 求最长单调递增子序列,序列大小≤5000 题解: 蒟蒻弱写了一个O(n^2)的. 代码: 1 #include ...
- bzoj1669 [Usaco2006 Oct]Hungry Cows饥饿的奶牛
Description Farmer John养了N(1 <= N <= 5,000)头奶牛,每头牛都有一个不超过32位二进制数的正整数编号.FJ希望奶牛们在进食前,能按编号从小到大的顺序 ...
- bzoj:1666: [Usaco2006 Oct]Another Cow Number Game 奶牛的数字游戏
Description 奶牛们又在玩一种无聊的数字游戏.输得很郁闷的贝茜想请你写个程序来帮她在开局时预测结果.在游戏的开始,每头牛都会得到一个数N(1<=N<=1,000,000).此时奶 ...
- bzoj 1667: [Usaco2006 Oct]Cows on Skates滑旱冰的奶牛(BFS)
1667: [Usaco2006 Oct]Cows on Skates滑旱冰的奶牛 Time Limit: 1 Sec Memory Limit: 64 MBSec Special Judge S ...
- bzoj 1668: [Usaco2006 Oct]Cow Pie Treasures 馅饼里的财富(DP)
1668: [Usaco2006 Oct]Cow Pie Treasures 馅饼里的财富 Time Limit: 3 Sec Memory Limit: 64 MB Submit: 786 So ...
- bzoj 1670: [Usaco2006 Oct]Building the Moat护城河的挖掘(凸包)
1670: [Usaco2006 Oct]Building the Moat护城河的挖掘 Time Limit: 3 Sec Memory Limit: 64 MB Submit: 624 Sol ...
- bzoj 3375: [Usaco2004 Mar]Paranoid Cows 发疯的奶牛(二分)
3375: [Usaco2004 Mar]Paranoid Cows 发疯的奶牛 Time Limit: 10 Sec Memory Limit: 128 MB Submit: 28 Solved ...
- bzoj 1670 [Usaco2006 Oct]Building the Moat护城河的挖掘——凸包
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=1670 用叉积判断.注意两端的平行于 y 轴的. #include<cstdio> ...
最新文章
- debian9 没有ipv4
- . SQL多条件查询存储过程
- 数字图像与数字图像处理
- 《计算机科学概论》—第3章3.3节文本表示法
- 怎么查看电脑内存和配置_电脑内存不足处理方法,电脑卡死处理方法。
- python制作手机壁纸_Python爬取手机壁纸图片
- matlab矩阵作分钟平均,提高matlab运行速度和节省空间的心得合集(ZT)
- mysql 空值处理
- html 源码_(带手机版数据同步)中国风古典园林石业织梦模板 水墨风格园林艺术网站源码下载...
- Java从入门到精通
- java面试的职业规划怎么说_java面试技巧-职业规划有技巧
- 小程序apkg还原_狐妖小红娘手游背后,有这样一群“天真”的人
- 【转载】Web前端框架图
- data uploads php权限,【网站安全】取消data、uploads等有执行.php的权限
- NVIDIA GPU 运算能力列表
- 双十一数码好物指南,双十一不踩坑推荐
- uniapp 登录页跳转到首页
- 微信小程序泛滥的今天,你知道如何测试吗?
- Kile 2.1.3 发布,TeX/LaTeX 集成编辑器
- clickhouse集群搭建