結果

問題 No.198 キャンディー・ボックス2
ユーザー はむ吉🐹はむ吉🐹
提出日時 2016-03-07 20:36:17
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 483 bytes
コンパイル時間 195 ms
コンパイル使用メモリ 11,992 KB
実行使用メモリ 17,488 KB
最終ジャッジ日時 2023-10-24 20:15:16
合計ジャッジ時間 4,344 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
import statistics


def main():
    num_a_cand = int(input())
    num_boxes = int(input())
    box_candies = array.array("L", (int(input()) for _ in range(num_boxes)))
    sum_of_candies = num_a_cand + sum(box_candies)
    aim = statistics.median_low(box_candies)
    while aim * num_boxes > sum_of_candies:
        aim -= 1
    print(sum(map(lambda c: abs(c - aim), box_candies)))


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