Created
May 5, 2023 14:23
-
-
Save modos/f5adf0c7b2c00710b675b38470fb824b 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
n, d = map(int, input().split()) | |
h = list(map(int, input().split())) | |
h.sort() | |
tallest = h[-1] | |
ans = 0 | |
for i in range(n - 1): | |
if tallest - h[i] > d: | |
ans += tallest - h[i] - d | |
print(ans) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment