Created
October 3, 2015 07:34
-
-
Save chmllr/df1dcfdc59577c9d9481 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var n = readline(); | |
var houses = readline().split(" "); | |
var max = -1, L = houses.length, result = new Array(n); | |
for (var i = L-1; i>=0; --i) { | |
var T = houses[i]; | |
result[i] = T > max ? 0 : max - T + 1; | |
max = Math.max(T, max); | |
} | |
print(result.join(" ")); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
readline(); | |
var houses = readline().split(" "); | |
var max = -1, L = houses.length, result = []; | |
for (var i = L-1; i>=0; --i) { | |
var T = houses[i]; | |
result.push(T > max ? 0 : max - T + 1); | |
max = Math.max(T, max); | |
} | |
result.reverse(); | |
print(result.join(" ")); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment