首页 > 其他 > 详细

ural 1252. Sorting the Tombstones

时间:2015-12-26 11:38:51      阅读:180      评论:0      收藏:0      [点我收藏+]

1252. Sorting the Tombstones

Time limit: 1.0 second
Memory limit: 64 MB
There is time to throw stones and there is time to sort stones…
An old desolate cemetery is a long dismal row of nameless tombstones There are N tombstones of various shapes. The weights of all the stones are different. People have decided to make the cemetery look more presentable, sorting the tombstone according to their weight. The local custom allows to transpose stones if there are exactly K other stones between them.

Input

The first input line contains an integer N (1 ≤ N ≤ 130000). Each of the next N lines contains an integer X, the weight of a stone in grams (1 ≤ X ≤ 130000).

Output

The output should contain the single integer — the maximal value of K (0 ≤ K < N), that makes possible the sorting of the stones according to their weights.

Sample

inputoutput
5
30
21
56
40
17
1
Problem Author: Alexey Lakhtin
Problem Source: Open collegiate programming contest for student teams, Ural State University, March 15, 2003

ural 1252. Sorting the Tombstones

原文:http://www.cnblogs.com/StupidBoy/p/5077692.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!