CF581B.Luxurious Houses
普及-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all the houses with larger numbers. In other words, a house is luxurious if the number of floors in it is strictly greater than in all the houses, which are located to the right from it. In this task it is assumed that the heights of floors in the houses are the same.
The new architect is interested in n questions, i-th of them is about the following: "how many floors should be added to the i-th house to make it luxurious?" (for all i from 1 to n, inclusive). You need to help him cope with this task.
Note that all these questions are independent from each other — the answer to the question for house i does not affect other answers (i.e., the floors to the houses are not actually added).
贝尔兰首都拥有 n 座多层建筑。建造首都的建筑师极富创造力,因此所有建筑都建在一条直线上。
我们从左到右依次为所有建筑编号,起始编号为 1。若一座建筑的楼层数严格大于所有编号更大的建筑的楼层数,则称该建筑为“豪华建筑”。换言之,若一座建筑的楼层数严格大于其右侧所有建筑的楼层数,则该建筑为豪华建筑。本题中假设各建筑每层高度相同。
新任建筑师提出了 n 个问题,其中第 i 个问题是:“需向第 i 座建筑添加多少层楼,才能使其成为豪华建筑?”(i 取遍 1 到 n 的所有整数)。你需要帮助他解决这一任务。
注意:这些问题彼此独立——对第 i 座建筑提问的答案不会影响其他问题的答案(即实际并不向建筑添加楼层)。
输入格式
The first line of the input contains a single number n (1 ≤ n ≤ 105) — the number of houses in the capital of Berland.
The second line contains n space-separated positive integers h__i (1 ≤ h__i ≤ 109), where h__i equals the number of floors in the i-th house.
输入的第一行包含一个整数 n(1 ≤ n ≤ 105)—— 表示贝尔兰首都的房屋数量。
第二行包含 n 个用空格分隔的正整数 hi(1 ≤ hi ≤ 109),其中 hi 表示第 i 栋房屋的楼层数。
输出格式
Print n integers _a_1, _a_2, ..., a__n, where number a__i is the number of floors that need to be added to the house number i to make it luxurious. If the house is already luxurious and nothing needs to be added to it, then a__i should be equal to zero.
All houses are numbered from left to right, starting from one.
输出 n 个整数 a1, a2, …, an,其中 ai 表示为使第 i 号房屋变为“豪华房屋”所需额外添加的楼层数。若该房屋已经是豪华房屋,无需添加任何楼层,则 ai 应为 0。
所有房屋从左至右依次编号,编号从 1 开始。
输入输出样例
输入#1
5 1 2 3 1 2
输出#1
3 2 0 2 0
输入#2
4 3 2 1 4
输出#2
2 3 4 0
输入解题思路,AI测评打分。不知道怎么写?