CF135A.Replacement
普及-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Little Petya very much likes arrays consisting of n integers, where each of them is in the range from 1 to 109, inclusive. Recently he has received one such array as a gift from his mother. Petya didn't like it at once. He decided to choose exactly one element from the array and replace it with another integer that also lies in the range from 1 to 109, inclusive. It is not allowed to replace a number with itself or to change no number at all.
After the replacement Petya sorted the array by the numbers' non-decreasing. Now he wants to know for each position: what minimum number could occupy it after the replacement and the sorting.
小佩佳非常喜欢由 n 个整数组成的数组,其中每个整数均在 1 到 109(含)之间。最近,他从母亲那里收到了这样一个数组作为礼物。佩佳起初并不喜欢它。他决定恰好选择数组中的一个元素,并将其替换为另一个同样在 1 到 109(含)范围内的整数。不允许将某个数替换成它自身,也不允许不作任何修改。
替换完成后,佩佳按非递减顺序对数组进行了排序。现在,他想知道:对于排序后数组的每一个位置,该位置上可能出现的最小可能数值是多少?
输入格式
The first line contains a single integer n (1 ≤ n ≤ 105), which represents how many numbers the array has. The next line contains n space-separated integers — the array's description. All elements of the array lie in the range from 1 to 109, inclusive.
第一行包含一个整数 n(1≤n≤105),表示数组中元素的个数。
下一行包含 n 个用空格分隔的整数——即该数组的描述。数组的所有元素均在 1 到 109(含)范围内。
输出格式
Print n space-separated integers — the minimum possible values of each array element after one replacement and the sorting are performed.
输出 n 个空格分隔的整数——在执行一次替换并排序后,每个数组元素可能的最小值。
输入输出样例
输入#1
5 1 2 3 4 5
输出#1
1 1 2 3 4
输入#2
5 2 3 4 5 6
输出#2
1 2 3 4 5
输入#3
3 2 2 2
输出#3
1 2 2
输入解题思路,AI测评打分。不知道怎么写?