A8297 | Replacement
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Little Petya very much likes arrays consisting of $n$ integers, where each of them is in the range from $1$ to $10^{9}$ , 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 $10^{9}$ , 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.
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.
输入格式
The first line contains a single integer $n$ ( $1<=n<=10^{5}$ ), 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 $10^{9}$ , inclusive.
输出格式
Print $n$ space-separated integers — the minimum possible values of each array element after one replacement and the sorting are performed.
输入输出样例
输入 #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
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted