LIS
来源:互联网 发布:c语言关机小病毒制作 编辑:程序博客网 时间:2024/05/01 10:56
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxn = 1e5 + 5;
struct Stack {
int n, s[maxn];
void init() { n = 0; }
int find (int x) { return upper_bound(s, s + n, x) - s; }
void insert(int p, int x) {
s[p] = x;
n = max(n, p + 1);
}
}S;
int N, A[maxn], dp[maxn];
bool judge () {
S.init();
int ans = 0;
for (int i = 1; i <= N; i++) {
dp[i] = S.find(A[i]);
S.insert(dp[i], A[i]);
ans = max(ans, dp[i] + 1);
}
return ans >= N-1;
}
int main () {
int cas;
scanf("%d", &cas);
while (cas--) {
scanf("%d", &N);
for (int i = 1; i <= N; i++) scanf("%d", &A[i]);
bool flag = judge();
reverse(A + 1, A + N + 1);
flag |= judge();
printf("%s\n", flag ? "YES" : "NO");
}
return 0;
}
- LIS
- LIS
- LIS
- LIS
- LIS
- LIS
- LIS
- LIS
- LIS
- LIS
- LIS
- LIS
- LIS
- LIS++
- lis
- lis
- LIS
- Lis
- onSaveInstanceState() 和 onRestoreInstanceState()方法
- libuv流程
- maven+springmvc+dubbo的简单配置
- 接口
- 5.相同的线程(Same-threading)
- LIS
- 移植 FFMPEG 3.0 到 Hi3531
- RSA algorithm
- 删除文件没有权限
- EFDatabase.ExecuteSqlCommand 返回值
- java-1.5-1.9新特性
- HDOJ/HDU 1180 诡异的楼梯(经典BFS-详解)
- XYC2016上半年工作笔记整理
- 多态与抽象