hdu 4991 Ordered Subsequence
来源:互联网 发布:财经类重要数据 编辑:程序博客网 时间:2024/05/29 03:33
Ordered Subsequence
Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 53 Accepted Submission(s): 29
Problem Description
A numeric sequence of ai is ordered if a1<a2<……<aN. Let the subsequence of the given numeric sequence (a1, a2,……, aN) be any sequence (ai1, ai2,……, aiK), where 1<=i1<i2 <……<iK<=N. For example, sequence (1, 7, 3, 5, 9, 4, 8) has ordered subsequences, eg. (1, 7), (3, 4, 8) and many others.
Your program, when given the numeric sequence, must find the number of its ordered subsequence with exact m numbers.
Your program, when given the numeric sequence, must find the number of its ordered subsequence with exact m numbers.
Input
Multi test cases. Each case contain two lines. The first line contains two integers n and m, n is the length of the sequence and m represent the size of the subsequence you need to find. The second line contains the elements of sequence - n integers in the range from 0 to 987654321 each.
Process to the end of file.
[Technical Specification]
1<=n<=10000
1<=m<=100
Process to the end of file.
[Technical Specification]
1<=n<=10000
1<=m<=100
Output
For each case, output answer % 123456789.
Sample Input
3 21 1 27 31 7 3 5 9 4 8
Sample Output
212
Source
BestCoder Round #8
首先数字有1万个,先离散化一下,把所有数字对应到1到n之间。这样对结果不影响。dp[i][j]代表以第i个数字结尾上升子序列长度为j的种数。dp[i][j]=sum{dp[k][j-1]} for each a[k]<a[i]&&k<i直接写循环会超时。需要优化。可以用平衡树进行优化,上述的循环过程可以看成是一个区间求和过程。用线段树或者树状数组可以解决。这样最终的复杂度是n*m*log(n)
0 0
- HDU-4991-Ordered Subsequence
- hdu 4991 Ordered Subsequence
- HDU 4991 Ordered Subsequence
- 【树状数组】 HDU 4991 Ordered Subsequence
- hdu 4991 Ordered Subsequence(dp+树状数组)
- HDU 4991 Ordered Subsequence -- DP+树状数组
- HDU 4991 / BC 8C Ordered Subsequence
- 【HDU】4991 Ordered Subsequence 线段树&树状数组
- hdu 4991 Ordered Subsequence(树状数组优化DP)
- hdu 4991 Ordered Subsequence(Bestcoder Round #8 1003)
- hdu 4991 Ordered Subsequence(DP优化—树状数组)
- HDU 4991 Ordered Subsequence(dp+树状数组)
- hdu 4991 Ordered Subsequence(树状数组+DP)
- HDU-4991-Ordered Subsequence【树状数组】【动态规划】【好题】
- HDU 4991 Ordered Subsequence DP(套路,BIT优化)
- 【DP】 HDOJ 4991 Ordered Subsequence
- HDU 4990 Ordered Subsequence --数据结构优化DP
- poj2553 Longest Ordered Subsequence
- 人脸识别的关键技术
- hdu 4990 Reading comprehension
- 查找出重复数字
- 人脸识别目前研究
- checkbox写法
- hdu 4991 Ordered Subsequence
- WSACreateEvent(),WSAEventSelect,WSAWaitForMultipleEvents(),WSAEnumNetworkEvents() .
- 人脸识别技术优势与行业应用
- 智能视觉物联网将拓展人脸识别应用
- Thread wait()和sleep()的区别
- C语言中以二进制形式输出整数
- 生物识别系统本领强 多领域应用威力无穷
- 利用ARP和ICMP协议解释ping命令(二)
- C++面试题1:构造函数和虚构函数中能否调用虚函数?