Beautiful Houses
InterviewTime limit1sMemory limit1024 MB
For each house, find how many floors it must gain to be taller than every house with a larger number, or 0 if it already is.
- Level
Easy3 of 10
- Topics
- Array
- Solved
- No attempts yet
Problem
In a certain city somewhere in Lithuania there is a very unusual street. The architect who planned it was so inventive that all houses stand on only one side of the street. The houses are numbered 1 to . A house farther from the start of the street has a larger number than a house closer to it. All houses look nearly identical, and only their heights differ.
As on any street, the residents want their homes to be beautiful. They agreed that a house is beautiful if it is taller than every house with a larger number.
Each resident wants to know whether their house is beautiful, and if not, how many floors it lacks to become beautiful.
Compute the shortfall for each house separately.
Note: residents who learn how many floors their houses lack will not build extra floors, so the shortfall of each house must be computed separately.
Input
The first line contains the number of houses . The second line contains integers , the height of the house numbered .
Output
Print integers , the number of floors the house numbered lacks to become beautiful. If a house is already beautiful, print for it.