結果
問題 |
No.198 キャンディー・ボックス2
|
ユーザー |
|
提出日時 | 2015-12-27 16:09:00 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 586 bytes |
コンパイル時間 | 77 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 10,752 KB |
最終ジャッジ日時 | 2024-09-19 07:23:41 |
合計ジャッジ時間 | 1,860 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 22 WA * 4 |
ソースコード
def func(n, candy_list, b): ans = 0 for c in candy_list: if c > n: d = c - n ans += d b += d elif c < n: d = n - c if d > b: return 10 ** 15 ans += d b -= d return ans def main(): b = int(input()) n = int(input()) candy_list = sorted([int(input()) for _ in range(n)], reverse=True) ans = 10 ** 15 for x in set(candy_list): ans = min(ans, func(x, candy_list, b)) print(ans) if __name__ == '__main__': main()