hdu1950 最大上升子序列
来源:互联网 发布:网络歌手作曲 编辑:程序博客网 时间:2024/05/17 07:09
题目:求最大的连续上升子序列。
思路:直接二分求,白皮书有详细讲解
#include <cstdio>#include <string>#include <cstring>#include <fstream>#include <algorithm>#include <cmath>#include <queue>#include <stack>#include <vector>#include <map>#include <set>#include <iostream>#include <iomanip>using namespace std;#define maxn 1000005#define MOD 1000000007#define mem(a) memset(a , 0 , sizeof(a))#define LL __int64#define INF 999999999int g[maxn];int arr[maxn];int main(){ int n , t; scanf("%d" , &t); while(t--) { scanf("%d" , &n) ; for(int i = 0 ; i < n ; i ++) scanf("%d" , &arr[i]); for(int i = 0 ; i < n ; i ++) g[i] = INF; int ans = 0; for(int i = 0 ; i < n ; i ++) { int k = lower_bound(g , g + n , arr[i]) - g; g[k] = arr[i]; ans = max(ans , k+1); } printf("%d\n" , ans); } return 0;}
0 0
- hdu1950 最大上升子序列
- HDU1950-Bridging signals-最长上升子序列
- 【DP】HDU1950 Bridging signals——LIS最大上升子序列算法
- HDU1950-Bridging signals(最长上升子序列)
- 【HDU1950】Bridging signals (最长上升子序列DP(nlogn))
- 最大上升子序列
- 最大上升子序列
- 最大上升子序列
- 最大上升子序列
- 1087 最大上升子序列
- 最大上升子序列和
- 最大上升子序列和
- 最大上升子序列和
- 最大上升子序列(LIS)
- 最大上升子序列和
- 最大上升子序列和
- 全部最大上升子序列
- 最大上升子序列-python
- 用MATLAB写一个发邮件的小程序
- php+mysql 简单增删查改
- OCMOD代码调整系统(Modification System)
- 终端克隆没权限以及生成git所需的SSH keys
- iOS Masonry Key debugging 调试详解
- hdu1950 最大上升子序列
- mycncart使用教程 - 如何修改网站后台用户名密码
- gregorian::date使用
- Hello Oninstack
- 如何为mycncart添加自定义链接
- Android 如何解决dialog弹出时无法捕捉Activity的back事件
- NSObject + NSCoding Category
- Maven设置代理服务器
- [Spring Boot 系列] 集成maven和Spring boot的profile功能