結果

問題 No.837 Noelちゃんと星々2
ユーザー H20
提出日時 2021-01-05 14:41:58
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 394 bytes
コンパイル時間 258 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 108,032 KB
最終ジャッジ日時 2024-10-15 20:17:52
合計ジャッジ時間 4,796 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 5 WA * 23 RE * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

import collections
N = int(input())
A = list(map(int,input().split()))
AC = collections.Counter(A)
if len(AC)==1:
    print(1)
    exit()
A.sort()
ME = A[N//2]
FH=[]
SH=[]
for i in range(N):
    if ME>=A[i]:
        FH.append(A[i])
    else:
        SH.append(A[i])
ans = 0
FM = FH[len(FH)//2]
SM = SH[len(SH)//2]
for f in FH:
    ans += abs(f-FM)
for s in SH:
    ans += abs(s-SM)
print(ans)

0