結果

問題 No.609 Noelちゃんと星々
ユーザー daku9640daku9640
提出日時 2018-08-11 22:02:07
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 355 bytes
コンパイル時間 310 ms
コンパイル使用メモリ 11,876 KB
実行使用メモリ 21,128 KB
最終ジャッジ日時 2023-10-24 14:07:19
合計ジャッジ時間 10,336 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 419 ms
18,328 KB
testcase_01 AC 224 ms
14,164 KB
testcase_02 AC 163 ms
12,976 KB
testcase_03 WA -
testcase_04 AC 115 ms
11,832 KB
testcase_05 AC 510 ms
20,408 KB
testcase_06 AC 441 ms
19,088 KB
testcase_07 AC 277 ms
15,316 KB
testcase_08 AC 78 ms
11,192 KB
testcase_09 AC 183 ms
13,268 KB
testcase_10 AC 330 ms
16,656 KB
testcase_11 AC 309 ms
16,092 KB
testcase_12 AC 394 ms
17,920 KB
testcase_13 AC 92 ms
11,400 KB
testcase_14 AC 54 ms
10,684 KB
testcase_15 AC 455 ms
19,096 KB
testcase_16 AC 534 ms
20,620 KB
testcase_17 WA -
testcase_18 AC 161 ms
12,676 KB
testcase_19 AC 442 ms
19,088 KB
testcase_20 AC 539 ms
21,128 KB
testcase_21 AC 539 ms
21,128 KB
testcase_22 AC 538 ms
21,128 KB
testcase_23 AC 539 ms
21,128 KB
testcase_24 AC 538 ms
21,128 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
y = tuple(map(int, input().split()))
m = {}
def f(a):
    if a not in m:
        cnt = 0
        for b in y:
            cnt += abs(b - a)
        m[a] = cnt
    return m[a]
l = min(y)
r = max(y)
while r - l > 2:
    if f(l) > f(r):
        l = (l * 2 + r) // 3
    else:
        r = (l + r * 2) // 3
print(min(f(l), f(l + 1), f(l + 2)))
0