Created
April 26, 2023 11:20
-
-
Save modos/1c3158bb83ab566b97ef6f1700cbe604 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 = 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