CF1392F.Omkar and Landslide

提高+/省选-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Omkar is standing at the foot of Celeste mountain. The summit is nn meters away from him, and he can see all of the mountains up to the summit, so for all 1≤j≤n1 \leq j \leq n he knows that the height of the mountain at the point jj meters away from himself is hjh_j meters. It turns out that for all jj satisfying 1≤j≤n−11 \leq j \leq n - 1, hj<hj+1h_j \lt h_{j + 1} (meaning that heights are strictly increasing).

Suddenly, a landslide occurs! While the landslide is occurring, the following occurs: every minute, if hj+2≤hj+1h_j + 2 \leq h_{j + 1}, then one square meter of dirt will slide from position j+1j + 1 to position jj, so that hj+1h_{j + 1} is decreased by 11 and hjh_j is increased by 11. These changes occur simultaneously, so for example, if hj+2≤hj+1h_j + 2 \leq h_{j + 1} and hj+1+2≤hj+2h_{j + 1} + 2 \leq h_{j + 2} for some jj, then hjh_j will be increased by 11, hj+2h_{j + 2} will be decreased by 11, and hj+1h_{j + 1} will be both increased and decreased by 11, meaning that in effect hj+1h_{j + 1} is unchanged during that minute.

The landslide ends when there is no jj such that hj+2≤hj+1h_j + 2 \leq h_{j + 1}. Help Omkar figure out what the values of h1,…,hnh_1, \dots, h_n will be after the landslide ends. It can be proven that under the given constraints, the landslide will always end in finitely many minutes.

Note that because of the large amount of input, it is recommended that your code uses fast IO.

奥马尔站在塞莱斯特山的山脚下。山顶距离他 nn 米,他能看见从当前位置一直到山顶的所有山体,因此对所有满足 1≤j≤n1 \leq j \leq n 的 jj,他都知道距离自己 jj 米处的山体高度为 hjh_j 米。事实上,对所有满足 1≤j≤n−11 \leq j \leq n - 1 的 jj,均有 hj<hj+1h_j \lt h_{j + 1}(即高度严格递增)。

突然,发生了山体滑坡!在滑坡过程中,每分钟都会发生如下变化:若对某个 jj 满足 hj+2≤hj+1h_j + 2 \leq h_{j + 1},则将有 11 平方米的泥土从位置 j+1j + 1 滑向位置 jj,使得 hj+1h_{j + 1} 减少 11,同时 hjh_j 增加 11。这些变化是同时发生的;例如,若对某个 jj 同时满足 hj+2≤hj+1h_j + 2 \leq h_{j + 1} 和 hj+1+2≤hj+2h_{j + 1} + 2 \leq h_{j + 2},那么 hjh_j 将增加 11,hj+2h_{j + 2} 将减少 11,而 hj+1h_{j + 1} 则既增加 11 又减少 11,因此该分钟内 hj+1h_{j + 1} 实际保持不变。

当不存在任何 jj 满足 hj+2≤hj+1h_j + 2 \leq h_{j + 1} 时,滑坡结束。请帮助奥马尔计算滑坡结束后 h1,…,hnh_1, \dots, h_n 的值。可以证明,在给定约束下,滑坡总会在有限分钟内结束。

注意:由于输入量较大,建议你的代码使用快速输入/输出(fast IO)。

输入格式

The first line contains a single integer nn (1≤n≤1061 \leq n \leq 10^6).

The second line contains nn integers h1,h2,…,hnh_1, h_2, \dots, h_n satisfying 0≤h1<h2<⋯<hn≤10120 \leq h_1 \lt h_2 \lt \dots \lt h_n \leq 10^{12} — the heights.

第一行包含一个整数 nn(1≤n≤1061 \leq n \leq 10^6)。

第二行包含 nn 个整数 h1,h2,…,hnh_1, h_2, \dots, h_n,满足 0≤h1<h2<⋯<hn≤10120 \leq h_1 \lt h_2 \lt \dots \lt h_n \leq 10^{12} —— 表示高度。

输出格式

Output nn integers, where the jj-th integer is the value of hjh_j after the landslide has stopped.

输出 nn 个整数,其中第 jj 个整数为滑坡停止后 hjh_j 的值。

输入输出样例

  • 输入#1

    4
    2 6 7 8

    输出#1

    5 5 6 7

说明/提示

Initially, the mountain has heights 2,6,7,82, 6, 7, 8.

In the first minute, we have 2+2≤62 + 2 \leq 6, so 22 increases to 33 and 66 decreases to 55, leaving 3,5,7,83, 5, 7, 8.

In the second minute, we have 3+2≤53 + 2 \leq 5 and 5+2≤75 + 2 \leq 7, so 33 increases to 44, 55 is unchanged, and 77 decreases to 66, leaving 4,5,6,84, 5, 6, 8.

In the third minute, we have 6+2≤86 + 2 \leq 8, so 66 increases to 77 and 88 decreases to 77, leaving 4,5,7,74, 5, 7, 7.

In the fourth minute, we have 5+2≤75 + 2 \leq 7, so 55 increases to 66 and 77 decreases to 66, leaving 4,6,6,74, 6, 6, 7.

In the fifth minute, we have 4+2≤64 + 2 \leq 6, so 44 increases to 55 and 66 decreases to 55, leaving 5,5,6,75, 5, 6, 7.

In the sixth minute, nothing else can change so the landslide stops and our answer is 5,5,6,75, 5, 6, 7.

最初,山的高度为 2,6,7,82, 6, 7, 8。

第一分钟,满足 2+2≤62 + 2 \leq 6,因此 22 增加至 33,66 减少至 55,得到 3,5,7,83, 5, 7, 8。

第二分钟,满足 3+2≤53 + 2 \leq 5 和 5+2≤75 + 2 \leq 7,因此 33 增加至 44,55 保持不变,77 减少至 66,得到 4,5,6,84, 5, 6, 8。

第三分钟,满足 6+2≤86 + 2 \leq 8,因此 66 增加至 77,88 减少至 77,得到 4,5,7,74, 5, 7, 7。

第四分钟,满足 5+2≤75 + 2 \leq 7,因此 55 增加至 66,77 减少至 66,得到 4,6,6,74, 6, 6, 7。

第五分钟,满足 4+2≤64 + 2 \leq 6,因此 44 增加至 55,66 减少至 55,得到 5,5,6,75, 5, 6, 7。

第六分钟,已无其他可变化的情况,滑坡停止,最终结果为 5,5,6,75, 5, 6, 7。

输入解题思路,AI测评打分。不知道怎么写?

首页