結果

問題 No.198 キャンディー・ボックス2
ユーザー noko2250noko2250
提出日時 2015-04-30 09:08:20
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 530 bytes
コンパイル時間 150 ms
コンパイル使用メモリ 10,968 KB
実行使用メモリ 7,988 KB
最終ジャッジ日時 2023-09-19 04:21:03
合計ジャッジ時間 2,197 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 17 ms
7,840 KB
testcase_09 AC 16 ms
7,760 KB
testcase_10 AC 16 ms
7,844 KB
testcase_11 WA -
testcase_12 AC 17 ms
7,888 KB
testcase_13 WA -
testcase_14 AC 17 ms
7,760 KB
testcase_15 AC 17 ms
7,740 KB
testcase_16 AC 17 ms
7,800 KB
testcase_17 AC 16 ms
7,828 KB
testcase_18 AC 16 ms
7,800 KB
testcase_19 WA -
testcase_20 AC 17 ms
7,892 KB
testcase_21 WA -
testcase_22 AC 17 ms
7,764 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 17 ms
7,756 KB
testcase_28 WA -
testcase_29 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #


def main():
    B = int(input())
    N = int(input())
    C = [0] * N
    for i in range(N):
        C[i] = int(input())
    ans = 10**10
    for i in range(N):
        r = C[i]
        dif = 0
        summ = 0
        for j in range(N):
            if i == j:
                continue
            dif += C[j] - r
            summ += abs(C[j] - r)
        if B + dif >= 0:
            ans = min(ans, summ)
        else:
            ans = min(ans, summ + ((B+dif+N-1)//N)*N)
    print(ans)

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