编程介的小学生 2019-06-01 14:33 采纳率: 20.5%
浏览 145

最长有序的子序列配对问题,怎么运用C语言的程序的代码编写的过程去实现的呢?

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.
S[ i , j ] indicates ( ai,ai+1,ai+2,…,aj) .
Your program, when given the numeric sequence (a1,a2,…,aN), must find the number of pair ( i, j) which makes the length of the longest ordered subsequence of S[ i , j ] equals to the length of the longest ordered subsequence of (a1,a2,…,aN).

Input
Multi test cases (about 100), every case occupies two lines, the first line contain n, then second line contain n numbers a1,a2,…,aN separated by exact one space.
Process to the end of file.

[Technical Specification]
1≤n≤100000
0≤ai≤1000000000

Output
For each case,.output the answer in a single line.

Sample Input
3
1 2 3
2
2 1

Sample Output
1
3

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥35 平滑拟合曲线该如何生成
    • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
    • ¥15 名为“Product”的列已属于此 DataTable
    • ¥15 安卓adb backup备份应用数据失败
    • ¥15 eclipse运行项目时遇到的问题
    • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
    • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
    • ¥15 自己瞎改改,结果现在又运行不了了
    • ¥15 链式存储应该如何解决
    • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站