結果
問題 |
No.1015 おつりは要らないです
|
ユーザー |
![]() |
提出日時 | 2020-06-12 23:41:12 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,513 bytes |
コンパイル時間 | 260 ms |
コンパイル使用メモリ | 81,932 KB |
実行使用メモリ | 97,408 KB |
最終ジャッジ日時 | 2024-06-24 06:05:23 |
合計ジャッジ時間 | 8,117 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 21 WA * 12 |
ソースコード
# 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: flag = False heapq.heappush(B, -x) 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: flag = False heapq.heappush(B, -x) 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")