結果

問題 No.609 Noelちゃんと星々
ユーザー FromBooskaFromBooska
提出日時 2023-03-18 20:10:36
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 79 ms / 2,000 ms
コード長 257 bytes
コンパイル時間 174 ms
コンパイル使用メモリ 81,840 KB
実行使用メモリ 86,252 KB
最終ジャッジ日時 2023-10-18 17:28:49
合計ジャッジ時間 3,771 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
80,076 KB
testcase_01 AC 52 ms
68,456 KB
testcase_02 AC 49 ms
65,964 KB
testcase_03 AC 50 ms
67,720 KB
testcase_04 AC 44 ms
64,288 KB
testcase_05 AC 76 ms
84,080 KB
testcase_06 AC 70 ms
80,496 KB
testcase_07 AC 56 ms
72,400 KB
testcase_08 AC 41 ms
61,608 KB
testcase_09 AC 48 ms
66,584 KB
testcase_10 AC 61 ms
74,784 KB
testcase_11 AC 60 ms
73,620 KB
testcase_12 AC 66 ms
76,512 KB
testcase_13 AC 42 ms
61,608 KB
testcase_14 AC 40 ms
59,560 KB
testcase_15 AC 72 ms
81,800 KB
testcase_16 AC 77 ms
84,056 KB
testcase_17 AC 69 ms
80,076 KB
testcase_18 AC 47 ms
65,944 KB
testcase_19 AC 70 ms
80,500 KB
testcase_20 AC 78 ms
84,204 KB
testcase_21 AC 79 ms
84,204 KB
testcase_22 AC 79 ms
86,252 KB
testcase_23 AC 79 ms
84,204 KB
testcase_24 AC 79 ms
86,252 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# medianまでの距離の和は、median後の要素の和 - median前の要素の和

N = int(input())
A = list(map(int, input().split()))
A.sort()
if N%2 == 0:
    ans = sum(A[N//2:])-sum(A[:N//2])
else:
    ans = sum(A[N//2+1:])-sum(A[:N//2])
print(ans)
0