結果

問題 No.609 Noelちゃんと星々
ユーザー rlangevinrlangevin
提出日時 2023-01-04 20:33:43
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 104 ms / 2,000 ms
コード長 241 bytes
コンパイル時間 356 ms
コンパイル使用メモリ 87,148 KB
実行使用メモリ 92,080 KB
最終ジャッジ日時 2023-08-18 17:36:33
合計ジャッジ時間 4,620 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 101 ms
87,936 KB
testcase_01 AC 84 ms
80,608 KB
testcase_02 AC 75 ms
78,624 KB
testcase_03 AC 80 ms
79,908 KB
testcase_04 AC 72 ms
76,844 KB
testcase_05 AC 101 ms
92,008 KB
testcase_06 AC 96 ms
88,124 KB
testcase_07 AC 80 ms
82,516 KB
testcase_08 AC 67 ms
76,380 KB
testcase_09 AC 75 ms
79,140 KB
testcase_10 AC 88 ms
84,556 KB
testcase_11 AC 85 ms
83,700 KB
testcase_12 AC 90 ms
86,532 KB
testcase_13 AC 70 ms
76,292 KB
testcase_14 AC 66 ms
76,300 KB
testcase_15 AC 97 ms
89,704 KB
testcase_16 AC 100 ms
91,656 KB
testcase_17 AC 91 ms
87,968 KB
testcase_18 AC 74 ms
78,296 KB
testcase_19 AC 92 ms
88,344 KB
testcase_20 AC 103 ms
91,888 KB
testcase_21 AC 99 ms
92,080 KB
testcase_22 AC 99 ms
91,692 KB
testcase_23 AC 99 ms
91,760 KB
testcase_24 AC 104 ms
91,964 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def calc(A, n):
    val = 0
    for a in A:
        val += abs(A[n] - a)
    return val 

N = int(input())
Y = list(map(int, input().split()))
Y.sort()
if N % 2:
    print(calc(Y, N//2))
else:
    print(min(calc(Y, N//2), calc(Y, N//2 - 1)))
0