結果
問題 | No.1015 おつりは要らないです |
ユーザー |
![]() |
提出日時 | 2020-06-12 23:53:21 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 194 ms / 2,000 ms |
コード長 | 1,700 bytes |
コンパイル時間 | 565 ms |
コンパイル使用メモリ | 82,568 KB |
実行使用メモリ | 97,388 KB |
最終ジャッジ日時 | 2024-11-18 07:22:48 |
合計ジャッジ時間 | 5,832 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 33 |
ソースコード
# problem 3 import math import heapq N, X, Y, Z = map(int, input().split()) A = list(map(int, input().split())) B = [] for num in A: B.append(-num-1) heapq.heapify(B) flag = True # 10000円処理のケース while flag and B: x = heapq.heappop(B)*(-1) if x < 10000: if Z == 0: heapq.heappush(B, -x) flag = False continue elif Z > 0: Z -= 1 continue elif x >= 10000: u, v = divmod(x, 10000) if u < Z: Z -= u heapq.heappush(B, -v) continue elif u >= Z: x -= Z*10000 Z = 0 heapq.heappush(B, -x) flag = False if not B: print("Yes") exit() flag = True # 5000円のケース while flag and B: x = heapq.heappop(B)*(-1) if x < 5000: if Y == 0: heapq.heappush(B, -x) flag = False continue elif Y > 0: Y -= 1 continue elif x >= 5000: u, v = divmod(x, 5000) if u < Y: Y -= u heapq.heappush(B, -v) continue elif u >= Y: x -= Y*5000 Y = 0 heapq.heappush(B, -x) flag = False if not B: print("Yes") exit() # 1000円の場合 flag = True judge = True Left = Y+Z while B and flag: x = heapq.heappop(B)*(-1) if Left > 0: Left -= 1 continue else: u = math.ceil(x/1000) if X >= u: X -= u continue else: flag = False judge = False continue if judge: print("Yes") else: print("No")