NOYJ-拦截导弹
来源:互联网 发布:盛科网络 营收 编辑:程序博客网 时间:2024/06/05 10:26
思路:
最长非递增序列:
太懒了,想用lower_bound 就把数组反过来存了,变成了最长非递减子序列
#include <iostream>#include <stdio.h>#include <algorithm>#include <cstring>using namespace std;int a[100];int b[100];void solve(int n){ int cot=1; b[1]=a[n]; for(int i=n-1;i>=1;i--) { if(a[i]>=b[cot]) { b[++cot]=a[i]; } else { b[lower_bound(b+1,b+1+cot,a[i])-b]=a[i]; } } cout<<cot<<endl;}int main(){ int T; cin>>T; while(T--) { memset(a,0,sizeof(a)); memset(b,0,sizeof(b)); int n; cin>>n; for(int i=1;i<=n;i++) { cin>>a[i]; } solve(n); } return 0;}
0 0
- NOYJ-拦截导弹
- 拦截导弹
- 拦截导弹
- 拦截导弹
- 拦截导弹
- 导弹拦截
- 导弹拦截
- 拦截导弹
- 拦截导弹
- 拦截导弹
- 拦截导弹
- 拦截导弹
- 拦截导弹
- 拦截导弹
- 拦截导弹
- 拦截导弹
- 拦截导弹
- 拦截导弹
- codeforces 486B OR in Matrix(位运算)
- Qt数据库 QSqlQueryModel实例操作
- 《卓有成效的程序员》笔记
- 最小堆第k小的元素与给定x的大小关系(编程题)
- java实现快速排序(利用随机索引)
- NOYJ-拦截导弹
- 你不知道的Java学习笔记20-- 多线程编程
- 1002
- 操作系统
- C 菜单浏览
- Android开发中的Tips
- 杭电 2070 Fibbonacci Number
- 关于数学。
- 关于矩阵表示(matrix-based expression)