编程介的小学生 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
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?
  • ¥15 乘性高斯噪声在深度学习网络中的应用
  • ¥15 运筹学排序问题中的在线排序
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛