【BZOJ】1669: [Usaco2006 Oct]Hungry Cows饥饿的奶牛(lis)
http://www.lydsy.com/JudgeOnline/problem.php?id=1669
水题太严重
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define for1(i,a,n) for(int i=(a);i<=(n);++i)
#define for2(i,a,n) for(int i=(a);i<(n);++i)
#define for3(i,a,n) for(int i=(a);i>=(n);--i)
#define for4(i,a,n) for(int i=(a);i>(n);--i)
#define CC(i,a) memset(i,a,sizeof(i))
#define read(a) a=getint()
#define print(a) printf("%d", a)
#define dbg(x) cout << #x << " = " << x << endl
#define printarr(a, n, m) rep(aaa, n) { rep(bbb, m) cout << a[aaa][bbb]; cout << endl; }
inline const int getint() { int r=0, k=1; char c=getchar(); for(; c<'0'||c>'9'; c=getchar()) if(c=='-') k=-1; for(; c>='0'&&c<='9'; c=getchar()) r=r*10+c-'0'; return k*r; }
inline const int max(const int &a, const int &b) { return a>b?a:b; }
inline const int min(const int &a, const int &b) { return a<b?a:b; }
bool cmp(int x, int y) { return x<=y; }
int a[5005], f[5005], g[5005];
int main() {
int n=getint(), ans=0;
for1(i, 1, n) read(a[i]);
CC(g, 0x7f);
for1(i, 1, n) {
int t=lower_bound(g+1, g+1+i, a[i], cmp)-g;
f[i]=t;
g[t]=a[i];
ans=max(ans, t);
}
print(ans);
return 0;
}
Description
Input
Output
Sample Input
2 5 18 3 4 7 10 9 11 8 15
Sample Output
HINT
Source
【BZOJ】1669: [Usaco2006 Oct]Hungry Cows饥饿的奶牛(lis)的更多相关文章
- BZOJ 1669: [Usaco2006 Oct]Hungry Cows饥饿的奶牛( LIS )
裸的LIS ----------------------------------------------------------------- #include<cstdio> #incl ...
- bzoj 1669: [Usaco2006 Oct]Hungry Cows饥饿的奶牛【dp+树状数组+hash】
最长上升子序列.虽然数据可以直接n方但是另写了个nlogn的 转移:f[i]=max(f[j]+1)(a[j]<a[i]) O(n^2) #include<iostream> #in ...
- BZOJ1669: [Usaco2006 Oct]Hungry Cows饥饿的奶牛
1669: [Usaco2006 Oct]Hungry Cows饥饿的奶牛 Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 665 Solved: 419 ...
- 【动态规划】bzoj1669 [Usaco2006 Oct]Hungry Cows饥饿的奶牛
#include<cstdio> #include<algorithm> using namespace std; int n,a[5001],b[5001],en; int ...
- 「BZOJ1669」D 饥饿的牛 [Usaco2006 Oct] Hungry Cows 牛客假日团队赛5 (LIS,离散化树状数组)
链接:https://ac.nowcoder.com/acm/contest/984/D 来源:牛客网 饥饿的牛 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 32768K,其他语言 ...
- bzoj:1666: [Usaco2006 Oct]Another Cow Number Game 奶牛的数字游戏
Description 奶牛们又在玩一种无聊的数字游戏.输得很郁闷的贝茜想请你写个程序来帮她在开局时预测结果.在游戏的开始,每头牛都会得到一个数N(1<=N<=1,000,000).此时奶 ...
- bzoj 1666: [Usaco2006 Oct]Another Cow Number Game 奶牛的数字游戏【模拟】
模拟 #include<iostream> #include<cstdio> using namespace std; int n,ans; int main() { scan ...
- BZOJ 1666: [Usaco2006 Oct]Another Cow Number Game 奶牛的数字游戏 幼儿园测试题
本来以为是一道数学题,一顿XJBT导式子,结果就是个幼儿园都会的模拟. Code: #include<bits/stdc++.h> #define ll long long using n ...
- BZOJ1666: [Usaco2006 Oct]Another Cow Number Game 奶牛的数字游戏
1666: [Usaco2006 Oct]Another Cow Number Game 奶牛的数字游戏 Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 5 ...
随机推荐
- ant design pro (十六)advanced 权限管理
一.概述 原文地址:https://pro.ant.design/docs/authority-management-cn 权限控制是中后台系统中常见的需求之一,你可以利用我们提供的权限控制组件,实现 ...
- Java Executor 线程池
- CommonClassLoader或SharedClassLoader加载的Spring如何访问并不在其加载范围内的用户程序呢
Question 引自<深入理解Java虚拟机—JVM高级特性与最佳实践>9.2.1,p235 如果有10个WEB应用程序都是用spring来进行组织管理的话,可以把Spring放到Com ...
- webp转jpg
webp转jpg CreateTime--2017年12月8日09:32:38 Author:Marydon 1.webp格式介绍 WebP 的优势体现在它具有更优的图像数据压缩算法,能带来更小的 ...
- php后台“爬虫”模拟登录第三方系统
http://blog.csdn.net/liu_c_y/article/details/49956679 http://www.php100.com/html/webkaifa/PHP/PHPyin ...
- 怎样给ExecutorService异步计算设置超时
ExecutorService接口使用submit方法会返回一个Future<V>对象.Future表示异步计算的结果.它提供了检查计算是否完毕的方法,以等待计算的完毕,并获取计算的结果. ...
- RFID编码
信号编码系统包括信源编码和信道编码两大类,器作用是把要传输的信息尽可能的与传输信道相匹配,并提供对信息的某种保护以防止信息受到干扰.信源编码与信源译码的目的是提高信息传输的有效性以及完成模数转换等:信 ...
- [转]C#如何判断操作系统位数是32位还是64位
方法一: 对于C#来说,调用WMI是一种简单易行的方式.我们可以用Win32_Processor类里面的AddressWidth属性来表示系统的位宽.AddressWidth的值受CPU和操作系统的双 ...
- Mysql使用大全 从基础到存储过程
平常习惯了phpmyadmin等其他工具的的朋友有的根本就不会命令,如果让你笔试去面试我看你怎么办,所以,学习一下还是非常有用的,也可以知道你通过GUI工具的时候工具到底做了什么.Mysql用处很广, ...
- AESDK AE中层类型的3种取得方式
有一部分属于类型标志,比如调节层,空对象层.用mSuites->LayerSuite7()->AEGP_GetLayerFlags去取 而灯光,文字这些信息,直接取类型即可 mSuites ...