結果

問題 No.198 キャンディー・ボックス2
ユーザー hiragnhiragn
提出日時 2022-11-19 00:08:58
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 426 bytes
コンパイル時間 540 ms
コンパイル使用メモリ 11,764 KB
実行使用メモリ 66,232 KB
最終ジャッジ日時 2023-10-20 08:59:08
合計ジャッジ時間 4,960 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 526 ms
42,304 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 509 ms
42,304 KB
testcase_20 WA -
testcase_21 AC 513 ms
42,304 KB
testcase_22 WA -
testcase_23 AC 512 ms
42,304 KB
testcase_24 WA -
testcase_25 AC 515 ms
42,304 KB
testcase_26 AC 507 ms
42,304 KB
testcase_27 WA -
testcase_28 AC 509 ms
42,304 KB
testcase_29 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import numpy as np


def main():
    b = int(input())
    n = int(input())
    c = np.array([int(input()) for _ in range(n)], dtype='int64')

    # bが小さいと中央値np.median(c)を実現できない。
    # n * x = sum(c) + bをみたすxと中央値の小さい方を作る
    x = min(np.median(c), (np.sum(c) + b) // n)
    ans = sum([abs(i - x) for i in c])
    print(ans)


if __name__ == "__main__":
    main()
0