Skip to content

Instantly share code, notes, and snippets.

@modos
Created April 26, 2023 11:20
Show Gist options
  • Save modos/1c3158bb83ab566b97ef6f1700cbe604 to your computer and use it in GitHub Desktop.
Save modos/1c3158bb83ab566b97ef6f1700cbe604 to your computer and use it in GitHub Desktop.
میانه صحیح
n = int(input())
a = sorted([int(x) for x in input().split()])
M = a[(n-1)//2]
ans = 0
for i in range(n):
ans += abs(a[i] - M)
print(M, ans)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment