C. Replacement
time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

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.

Input

The first line contains a single integer n (1 ≤ n ≤ 105), which represents how many numbers the array has. The next line contains nspace-separated integers — the array's description. All elements of the array lie in the range from 1 to 109, inclusive.

Output

Print n space-separated integers — the minimum possible values of each array element after one replacement and the sorting are performed.

Examples
input
5
1 2 3 4 5
output
1 1 2 3 4
input
5
2 3 4 5 6
output
1 2 3 4 5
input
3
2 2 2
output
1 2 2
题意:改变一个数使得字典序最小;
思路:改变最大值;全是1是坑点;
 #include<bits/stdc++.h>
using namespace std;
#define ll __int64
#define mod 1000000007
#define inf 100000000000005
#define MAXN 10000010
//#pragma comment(linker, "/STACK:102400000,102400000")
int a[];
int main()
{
int x,y,z,i,t;
scanf("%d",&x);
for(i=;i<x;i++)
scanf("%d",&a[i]);
sort(a,a+x);
if(a[x-]!=)
a[x-]=;
else
a[x-]=;
sort(a,a+x);
for(i=;i<x;i++)
printf("%d ",a[i]);
return ;
}

codeforces 97 div2 C.Replacement 水题的更多相关文章

  1. codeforces 98 div2 C.History 水题

    C. History time limit per test 2 seconds memory limit per test 256 megabytes input standard input ou ...

  2. codeforces 577B B. Modulo Sum(水题)

    题目链接: B. Modulo Sum time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  3. Codeforces Round #367 (Div. 2)---水题 | dp | 01字典树

    A.Beru-taxi 水题:有一个人站在(sx,sy)的位置,有n辆出租车,正向这个人匀速赶来,每个出租车的位置是(xi, yi) 速度是 Vi;求人最少需要等的时间: 单间循环即可: #inclu ...

  4. codeforces 696A Lorenzo Von Matterhorn 水题

    这题一眼看就是水题,map随便计 然后我之所以发这个题解,是因为我用了log2()这个函数判断在哪一层 我只能说我真是太傻逼了,这个函数以前听人说有精度问题,还慢,为了图快用的,没想到被坑惨了,以后尽 ...

  5. CodeForces 589I Lottery (暴力,水题)

    题意:给定 n 和 k,然后是 n 个数,表示1-k的一个值,问你修改最少的数,使得所有的1-k的数目都等于n/k. 析:水题,只要用每个数减去n/k,然后取模,加起来除以2,就ok了. 代码如下: ...

  6. Codeforces Gym 100286G Giant Screen 水题

    Problem G.Giant ScreenTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/con ...

  7. codeforces 710A A. King Moves(水题)

    题目链接: A. King Moves 题意: 给出king的位置,问有几个可移动的位置; 思路: 水题,没有思路; AC代码: #include <iostream> #include ...

  8. codeforces 659A A. Round House(水题)

    题目链接: A. Round House time limit per test 1 second memory limit per test 256 megabytes input standard ...

  9. CodeForces 489B BerSU Ball (水题 双指针)

    B. BerSU Ball time limit per test 1 second memory limit per test 256 megabytes input standard input ...

随机推荐

  1. wap启用宏

    vba for wps office是使用wps的时候开启宏需要的VBA安装包,安装好这个插件就可以开启wps的宏功能了,重新打开WPS Excel,可以看到上面的工具栏中宏选项变成可选的就成功了 1 ...

  2. EL表达式经验教训 javax.el.PropertyNotFoundException 出错

    之所以是把他记下来,是因为这个低级错误 害的我找了老半天. 后台传了对象到页面,在页面中循环遍历获得对象某个属性值 如下: <c:forEach items="${resultMap. ...

  3. wsdl客户端代码生成的方法

    在jdk的bin目录下有一个wsimport.exe的工具,使用该工具命令生产java客户端代码: 命令如下: wsimport  -keep -d d:\ -s d:\src -p com.map  ...

  4. MySQL慢查询日志工具mysqlsla

    mysql数据库的慢查询日志是非常重要的一项调优辅助日志,但是mysql默认记录的日志格式阅读时不够友好,这是由mysql日志记录规则所决定的,捕获一条就记录一条,虽说记录的信息足够详尽,但如果将浏览 ...

  5. Network of Schools---poj1236(强连通分量)

    题目链接 题意:学校有一些单向网络,现在需要传一些文件 求:1,求最少需要向几个学校分发文件才能让每个学校都收到, 2,需要添加几条网络才能从任意一个学校分发都可以传遍所有学校. 解题思路(参考大神的 ...

  6. Python开发【笔记】:git&github 快速入门

    github入门 简介: 很多人都知道,Linus在1991年创建了开源的Linux,从此,Linux系统不断发展,已经成为最大的服务器系统软件了. Linus虽然创建了Linux,但Linux的壮大 ...

  7. 优云老王的心路历程(二):下一站Web体验监控产品

    在上一篇文章中,和大家聊到了建立Web应用体验监控体系,经过了概念阶段,也完成了技术选型,就进入了把实质性的产品研发阶段.作为产品经理,时刻不敢忘记我们的产品目标:无限感知你的用户,建立完备的体验监控 ...

  8. MySQL 的mysqldump备份

    MySQL 的mysqldump备份 来自<mysql技术内幕 innodb存储引擎> --single-transaction:只对innodb表有效 --lock-tables:对My ...

  9. Underscore.js (1.7.0)-函数预览

    集合(Collections)(25) - each - map - reduce - reduceRight - find - filter - where - findWhere - reject ...

  10. 1059. C语言竞赛(20)

    原题: https://www.patest.cn/contests/pat-b-practise/1059 思路: 参赛者id是数组下标, 数组值是参赛者排名位置(从1开始), 每次判断0不存在, ...