結果
問題 |
No.1015 おつりは要らないです
|
ユーザー |
|
提出日時 | 2024-10-03 00:22:09 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 241 ms / 2,000 ms |
コード長 | 681 bytes |
コンパイル時間 | 174 ms |
コンパイル使用メモリ | 82,272 KB |
実行使用メモリ | 96,864 KB |
最終ジャッジ日時 | 2024-10-03 00:22:17 |
合計ジャッジ時間 | 7,401 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 33 |
ソースコード
from heapq import heappop, heappush N, X, Y, Z = map(int, input().split()) A = list(map(int, input().split())) hq = [] for a in A: heappush(hq, -a) def do(hq, c, num): while hq and num > 0: a = -heappop(hq) n = a // c if n == 0: if num: num -= 1 a -= c elif n <= num: a %= c num -= n else: a -= num * c num = 0 if a >= 0: heappush(hq, -a) if num == 0: break return hq hq = do(hq, 10000, Z) hq = do(hq, 5000, Y) hq = do(hq, 1000, X) if hq: print('No') else: print('Yes')