結果

問題 No.198 キャンディー・ボックス2
コンテスト
ユーザー はむ吉🐹
提出日時 2016-03-07 20:38:26
言語 Python3
(3.15.0 + numpy 2.5.4 + scipy 1.18.1 + ACL)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
AC  
実行時間 46 ms / 1,000 ms
+ 682µs
コード長 456 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 63 ms
コンパイル使用メモリ 15,104 KB
実行使用メモリ 14,892 KB
最終ジャッジ日時 2026-10-10 14:29:49
合計ジャッジ時間 3,785 ms
ジャッジサーバーID
(参考情報)
judge4_0 / judge5_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#!/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 = min(statistics.median_low(box_candies), sum_of_candies // num_boxes)
    print(sum(map(lambda c: abs(c - aim), box_candies)))


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