CF218A.Mountain Scenery
普及-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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 2_n_ segments. The segments go through 2_n_ + 1 points with coordinates (1, y_1), (2, y_2), ..., (2_n + 1, y_2_n + 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 ≤ 2_n) 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), ..., (2_n + 1, r_2_n + 1).
Given Bolek's final picture, restore the initial one.
小博莱克发现了一幅画有 n 座山峰的图画。这 n 座山峰由一条非封闭折线表示,该折线包含 2n 条线段。这些线段依次连接 2n+1 个点,其坐标为 (1,y1),(2,y2),…,(2n+1,y2n+1),其中第 i 条线段连接点 (i,yi) 和点 (i+1,yi+1)。对任意偶数 i(满足 2≤i≤2n),均满足如下条件:
yi−1<yi且yi>yi+1.
我们将横坐标为偶数的折线顶点称为山峰。

左侧图示为原始图画,右侧图示为博莱克操作后的图画。被修改的山峰以红色标出,此处 k=2。
博莱克起了点顽皮之心。他恰好选中了 k 座山峰,擦除了所有经过这些山峰的线段,并将每座被选中山峰的高度增加 1(即,将其对应点的 y 坐标加 1)。随后,他重新绘制了缺失的线段,从而得到一幅新的山峰图画。记新折线所经过的点为 (1,r1),(2,r2),…,(2n+1,r2n+1)。
现给定博莱克最终的图画(即全部 ri 值),请还原出初始图画(即全部 yi 值)。
输入格式
The first line contains two space-separated integers n and k (1 ≤ k ≤ n ≤ 100). The next line contains 2_n_ + 1 space-separated integers _r_1, _r_2, ..., r_2_n + 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.
第一行包含两个用空格分隔的整数 n 和 k(1≤k≤n≤100)。
下一行包含 2n+1 个用空格分隔的整数 r1, r2, …, r2n+1(0≤ri≤100)——即博莱克(Bolek)画作中折线顶点的 y 坐标。
题目保证:存在某幅山峰图像,对其执行上述操作后可恰好得到给定的图像。
输出格式
Print 2_n_ + 1 integers _y_1, _y_2, ..., y_2_n + 1 — the y coordinates of the vertices of the polyline on the initial picture. If there are multiple answers, output any one of them.
输出 2n+1 个整数 y1, y2, …, y2n+1 —— 初始图中折线各顶点的 y 坐标。若存在多个答案,输出任意一个即可。
输入输出样例
输入#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
输入解题思路,AI测评打分。不知道怎么写?