結果

問題 No.609 Noelちゃんと星々
ユーザー DexctersuDexctersu
提出日時 2018-01-31 14:55:58
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 130 ms / 2,000 ms
コード長 241 bytes
コンパイル時間 145 ms
コンパイル使用メモリ 10,592 KB
実行使用メモリ 19,012 KB
最終ジャッジ日時 2023-08-28 17:30:29
合計ジャッジ時間 3,599 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
16,484 KB
testcase_01 AC 56 ms
12,548 KB
testcase_02 AC 44 ms
11,316 KB
testcase_03 AC 45 ms
12,524 KB
testcase_04 AC 33 ms
10,220 KB
testcase_05 AC 120 ms
18,516 KB
testcase_06 AC 104 ms
16,940 KB
testcase_07 AC 57 ms
13,488 KB
testcase_08 AC 23 ms
9,212 KB
testcase_09 AC 41 ms
11,376 KB
testcase_10 AC 79 ms
14,580 KB
testcase_11 AC 74 ms
14,192 KB
testcase_12 AC 77 ms
15,808 KB
testcase_13 AC 28 ms
9,808 KB
testcase_14 AC 20 ms
8,788 KB
testcase_15 AC 106 ms
17,120 KB
testcase_16 AC 105 ms
18,688 KB
testcase_17 AC 84 ms
16,360 KB
testcase_18 AC 37 ms
11,264 KB
testcase_19 AC 107 ms
16,972 KB
testcase_20 AC 127 ms
18,876 KB
testcase_21 AC 129 ms
19,012 KB
testcase_22 AC 129 ms
18,832 KB
testcase_23 AC 130 ms
18,804 KB
testcase_24 AC 127 ms
18,828 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n=int(input())
a=list(map(int,input().split()))
a.sort()
dp=[]
med=len(a)//2
for i in range(n):
    if n%2!=0:
        dp.append(abs(a[i]-a[med]))
    else:
        med_i=(a[med]+a[med-1])//2
        dp.append(abs(a[i]-med_i))
print(sum(dp))
0