编程介的小学生 2017-09-03 12:38 采纳率: 20.5%
浏览 868
已采纳

Bone Sort

WishingBone has many bone sorters that can perform function as follows:

One day he happened to find out he could use several such bone sorters to construct super bone sorters. For instance, the figure below illustrates one way to construct a level 4 super bone sorter with six bone sorters, which can sort 4 arbitrary numbers.

But, as a doggie, he is sure thrift on bones. So he wonders what the minimal number of bone sorters to construct an n-super bone sorter could be. Besides, he does not actually need a general sorter, but one on some numbers he knows in advance, so that you may take this advantage in calculating the solution. (Suppose bone sorter can be placed on any pair of lines.)

By the way, he is also eager to know the inversion number of the original numbers. (He wants this value to evaluate the efficiency of his bone sorter.) Inversion number is the number of such pairs (Ai, Aj) that satisfies iAj.

Input

The first line of input is an integer N ( 0 < N <= 100000 ), which is the number of integers to be sorted.

The following N lines contain one integer on each line. All integers are distinct.

Output

The first line of output is the minimal number of bone sorters to construct the super sorter desired.

The second line is the inversion number.

Sample Input

3
-3
2
7

Sample Output

0
0

Sample Input

4
14
7
2
0

Sample Output

2
6

  • 写回答

1条回答

  • threenewbee 2017-09-17 14:41
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?