A8766 | Mountain Scenery
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Little Bolek has found a picture with $n$ mountain peaks painted on it. The $n$ painted peaks are represented by a non-closed polyline, consisting of $2n$ segments. The segments go through $2n+1$ points with coordinates $(1,y_{1})$ , $(2,y_{2})$ , $...$ , $(2n+1,y_{2n+1})$ , with the $i$ -th segment connecting the point $(i,y_{i})$ and the point $(i+1,y_{i+1})$ . For any even $i$ $(2<=i<=2n)$ the following condition holds: $y_{i-1}<y_{i}$ and $y_{i}>y_{i+1}$ .
We shall call a vertex of a polyline with an even $x$ coordinate a mountain peak.
 The figure to the left shows the initial picture, the figure to the right shows what the picture looks like after Bolek's actions. The affected peaks are marked red, $k$ = 2. Bolek fancied a little mischief. He chose exactly $k$ mountain peaks, rubbed out the segments that went through those peaks and increased each peak's height by one (that is, he increased the $y$ coordinate of the corresponding points). Then he painted the missing segments to get a new picture of mountain peaks. Let us denote the points through which the new polyline passes on Bolek's new picture as $(1,r_{1})$ , $(2,r_{2})$ , $...$ , $(2n+1,r_{2n+1})$ .
Given Bolek's final picture, restore the initial one.
We shall call a vertex of a polyline with an even $x$ coordinate a mountain peak.
 The figure to the left shows the initial picture, the figure to the right shows what the picture looks like after Bolek's actions. The affected peaks are marked red, $k$ = 2. Bolek fancied a little mischief. He chose exactly $k$ mountain peaks, rubbed out the segments that went through those peaks and increased each peak's height by one (that is, he increased the $y$ coordinate of the corresponding points). Then he painted the missing segments to get a new picture of mountain peaks. Let us denote the points through which the new polyline passes on Bolek's new picture as $(1,r_{1})$ , $(2,r_{2})$ , $...$ , $(2n+1,r_{2n+1})$ .
Given Bolek's final picture, restore the initial one.
输入格式
The first line contains two space-separated integers $n$ and $k$ $(1<=k<=n<=100)$ . The next line contains $2n+1$ space-separated integers $r_{1},r_{2},...,r_{2n+1}$ $(0<=r_{i}<=100)$ — the $y$ coordinates of the polyline vertices on Bolek's picture.
It is guaranteed that we can obtain the given picture after performing the described actions on some picture of mountain peaks.
It is guaranteed that we can obtain the given picture after performing the described actions on some picture of mountain peaks.
输出格式
Print $2n+1$ integers $y_{1},y_{2},...,y_{2n+1}$ — the $y$ coordinates of the vertices of the polyline on the initial picture. If there are multiple answers, output any one of them.
输入输出样例
输入 #1
3 2 0 5 3 5 1 5 2
输出 #1
0 5 3 4 1 4 2
输入 #2
1 1 0 2 0
输出 #2
0 1 0
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted