Integer Numbers zoj 3365
来源:互联网 发布:车销 软件 编辑:程序博客网 时间:2024/06/11 13:09
Time Limit: 1 Second Memory Limit: 32768 KB Special Judge
The boy likes numbers. He has a sheet of paper. He have written a sequence of consecutive integer numbers on the sheet. The boy likes them.
But then the girl came. The girl is cruel. She changed some of the numbers.
The boy is disappointed. He cries. He does not like all these random numbers. He likes consecutive numbers. He really likes them. But his numbers are not consecutive any more. The boy is disappointed. He cries.
Help the boy. He can change some numbers. He would not like to change many of them. He would like to change as few as possible. He cannot change their order. He would like the numbers to be consecutive again. Help the boy.
Input
The first line of the input file contains n --- the number of numbers in the sequence (1 ≤ n ≤ 50000). The next line contains the sequence itself --- integer numbers not exceeding 109 by their absolute values.
There are multiple cases. Process to the end of file.
Output
Output the minimal number of numbers that the boy must change. After that output the sequence after the change.
Sample Input
65 4 5 2 1 8
Sample Output
33 4 5 6 7 8
思路:每个点减去它的相对位置,得到的那串序列(sort(a[])序列)中出现频率最高的那个数就是最终每个数字的偏移量
- Integer Numbers zoj 3365
- ZOJ:3365 Integer Numbers
- ZOJ 3365 Integer Numbers 思路题
- hust-Integer Numbers
- ZOJ 1292 Integer Inquiry
- ZOJ 1292 Integer Inquiry
- zoj 1292 Integer Inquiry
- ZOJ 1292 Integer Inquiry
- ZOJ 1292 Integer Inquiry
- zoj 1292 Integer Inquiry
- zoj 1095 Humble Numbers
- zoj 1095 Humble Numbers
- ZOJ 1095 Humble Numbers
- ZOJ 1095 Humble Numbers
- zoj 1180 Self Numbers
- ZOJ 2000 Palindrome Numbers
- ZOJ 1154 Niven Numbers
- zoj 1133 Smith Numbers
- What I have done
- SQL新手报到
- SQL新手报到
- N 个元素的数组,求第K大的元素
- MFC下 报表打印程序的实现
- Integer Numbers zoj 3365
- poj2780解题报告
- 今天让我们一起为舟曲灾区同胞祝福
- Saving Princess
- Python 插件杂谈 (3) ---- PyQuery , Python中的网页分析利器
- 开源3d游戏引擎的一些了解
- 幻镜 一
- 【SQL*Plus】使用BREAK和COMPUTE在SQL*Plus中得到分组统计结果
- MindMapper 总结SQL Server