Skip to content

Instantly share code, notes, and snippets.

@modos
Created May 5, 2023 14:23
Show Gist options
  • Save modos/f5adf0c7b2c00710b675b38470fb824b to your computer and use it in GitHub Desktop.
Save modos/f5adf0c7b2c00710b675b38470fb824b to your computer and use it in GitHub Desktop.
عدالت یا برابری
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