Bellovin
2016-07-24 02:16
211 查看
链接:http://acm.hdu.edu.cn/showproblem.php?pid=5748
题意:对每一位的最长上升子序列,求出另一个序列。
例如:12435。
对第一位:1
对第二位:12
对第三位:124
对第四位:124
对第五位:1245
所以结果就是:12334。
所以对每一位都求一下最长上升子序列就好啦。
题意:对每一位的最长上升子序列,求出另一个序列。
例如:12435。
对第一位:1
对第二位:12
对第三位:124
对第四位:124
对第五位:1245
所以结果就是:12334。
所以对每一位都求一下最长上升子序列就好啦。
#include <cstdio> #include <algorithm> #include <cstring> #include <iostream> const int MAXN=100005; const int INF=0x3f3f3f3f; long long a[MAXN]; long long dp[MAXN]; using namespace std; int main (void) { int t; cin>>t; while(t--) { int num; scanf("%d",&num); memset(dp,0x3f,sizeof(dp)); for(int i=0;i<num;i++) { scanf("%lld",&a[i]); // dp[i]=INF; *lower_bound(dp,dp+num,a[i])=a[i]; long long le=lower_bound(dp,dp+num,a[i])-dp; printf("%lld%s",le+1,i==num-1?"\n":" "); } } return 0; }
相关文章推荐
- 【HDU 5366】The mook jong 详解
- 【HDU 2136】Largest prime factor 详细图解
- 【HDU 1568】Fibonacci 数学公式 详解
- HDU 1568
- HDU1290
- HDU1568(Fobonacci公式)
- HDU ACM Step 2.2.2 Joseph(约瑟夫环问题)
- HDU 1405
- HDU 1297
- hdu 1205
- hdu 2087
- hdu 1016
- HDU 4898 The Revenge of the Princess’ Knight ( 2014 Multi-University Training Contest 4 )
- HDU 5592 ZYB's Premutation 线段树(查找动态区间第K大)
- HDU 5240 Exam (好水的题)
- HDU5237 Base64 大模拟
- HDU 1000
- HDU 1001
- HDU 1016 Prime Ring Problem
- HDU 1017 A Mathematical Curiosity