hdu 4604 Deque(LIS)
来源:互联网 发布:思想深度 知乎 编辑:程序博客网 时间:2024/06/11 06:04
题目链接:hdu 4604 Deque
解题思路
枚举位置i,即以A[i]为最终序列的中间值,那么从[i,N]的区间内,以A[i]+1为起点的非递减序列可以在操作中插入deque的后端。以A[i]为起点的非递增序列可以在操作中插入deque的前端。
代码
#include <cstdio>#include <cstring>#include <algorithm>using namespace std;const int maxn = 100005;struct Stack { int n, s[maxn]; void init () { n = 0; } int find (int x) { return upper_bound(s, s + n, x) - s; } void modify(int pos, int val) { s[pos] = val; n = max(n, pos+1); }}in, de;int N, A[maxn];int solve () { in.init(); de.init(); int ret = 0; for (int i = N; i; i--) { int l = in.find(A[i]); in.modify(l, A[i]); int r = de.find(-(A[i]+1)); int tmp = de.find(-A[i]); de.modify(tmp, -A[i]); ret = max(ret, l + r); } return ret + 1;}int main () { int cas; scanf("%d", &cas); while (cas--) { scanf("%d", &N); for (int i = 1; i <= N; i++) scanf("%d", &A[i]); printf("%d\n", solve()); } return 0;}
0 0
- hdu 4604 Deque(LIS)
- HDU 4604 Deque(LIS 转化)
- HDU 4604 Deque(dp、LIS)
- LIS升级版-Deque HDU
- hdu 4604 Deque
- hdu 4604 Deque
- HDU 4604 Deque
- HDU 4604 Deque
- HDU 4604 Deque
- HDU 4604 Deque
- hdu 4604 Deque
- hdu 4604 Deque
- HDU 4604 Deque
- HDU 4604 lower_bound,LIS
- HDU 1257(LIS)
- HDU 4604 Deque 解题报告
- MUTC2013 E-Deque-hdu 4604
- HDU 4604 Deque(LCS DP)
- 机器视觉入门:K均值
- CreateThread 创建线程所引起的内存泄漏的问题
- leetcode之Maximum Subarray
- 软工及文档之大总结
- 解决方案--gloox源码编译错误
- hdu 4604 Deque(LIS)
- 洛谷1993小k的农场(差分约束系统)
- 【NGUI】Unity使用Resources加载NGUI的图片
- leetcode contains duplicate III
- UIImage剪切图片为自定义大小
- WebSocket形象理解
- 快速索引 (对View的自定义,黑马程序员)
- C# DataGridView内容合并相同的行
- R绘图lattice包