Problem 1864 --Sequence Number

1864: Sequence Number

"
Time Limit $1$ 秒/Second(s) Memory Limit $512$ 兆字节/Megabyte(s)
提交总数 $8$ 正确数量 $3$
裁判形式 标准裁判/Standard Judge 我的状态 尚未尝试
难度 分类标签

     In Linear algebra, we have learned the definition of inversion number:

    Assuming A is a ordered set with n numbers ( n > 1 ) which are different from each other. If exist positive integers i , j, ( 1 ≤ i < j ≤ n and A[i] > A[j]), <A[i], A[j]> is regarded as one of A’s inversions. The number of inversions is regarded as inversion number. Such as, inversions of array <2,3,8,6,1> are <2,1>, <3,1>, <8,1>, <8,6>, <6,1>,and the inversion number is 5.

     Similarly, we define a new notion —— sequence number, If exist positive integers i, j, ( 1 ≤ i ≤ j ≤ n and A[i]  <=  A[j], <A[i], A[j]> is regarded as one of A’s sequence pair. The number of sequence pairs is regarded as sequence number. Define j – i as the length of the sequence pair.

     Now, we wonder that the largest length S of all sequence pairs for a given array A. 

    There are multiply test cases.

    In each case, the first line is a number N(1<=N<=50000 ), indicates the size of the array, the 2th ~n+1th line are one number per line, indicates the element Ai (1<=Ai<=10^9) of the array.  

 Output the answer S in one line for each case. 

5
2 3 8 6 1
3

推荐代码 查看1864 所有题解 上传题解视频得图灵币

本题记录 用 户(点击查看用户) 运行号(点击购买题解) 时 间
算法最快[$60 $ms] 时涛涛@计算机科学与技术162 84370 2017-04-27 10:29:52
内存最少[$0 $KB] 淡意的温柔 588189 2020-05-28 11:09:21
第一AC 时涛涛@计算机科学与技术162 84370 2017-04-27 10:29:52
第一挑战 AOJ大管家 84156 2017-04-26 12:51:59

赛题来源/所属竞赛 NA N/A

竞赛编号 竞赛名称 竞赛时间 访问比赛
1080 2017ACM集训赛 2017-04-26 12:00:00 请登录