結果

問題 No.1015 おつりは要らないです
ユーザー w0mbatw0mbat
提出日時 2020-11-03 22:10:41
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 286 ms / 2,000 ms
コード長 661 bytes
コンパイル時間 222 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 92,160 KB
最終ジャッジ日時 2024-04-29 06:20:46
合計ジャッジ時間 7,897 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
52,096 KB
testcase_01 AC 43 ms
52,608 KB
testcase_02 AC 47 ms
52,096 KB
testcase_03 AC 42 ms
52,608 KB
testcase_04 AC 43 ms
52,224 KB
testcase_05 AC 42 ms
52,480 KB
testcase_06 AC 42 ms
52,352 KB
testcase_07 AC 43 ms
52,352 KB
testcase_08 AC 43 ms
52,352 KB
testcase_09 AC 43 ms
52,096 KB
testcase_10 AC 278 ms
91,264 KB
testcase_11 AC 282 ms
91,776 KB
testcase_12 AC 269 ms
91,264 KB
testcase_13 AC 275 ms
92,032 KB
testcase_14 AC 283 ms
91,648 KB
testcase_15 AC 270 ms
91,264 KB
testcase_16 AC 272 ms
91,520 KB
testcase_17 AC 286 ms
92,160 KB
testcase_18 AC 280 ms
91,264 KB
testcase_19 AC 272 ms
91,392 KB
testcase_20 AC 254 ms
91,136 KB
testcase_21 AC 245 ms
91,264 KB
testcase_22 AC 248 ms
91,264 KB
testcase_23 AC 247 ms
91,392 KB
testcase_24 AC 254 ms
91,648 KB
testcase_25 AC 249 ms
91,648 KB
testcase_26 AC 247 ms
91,264 KB
testcase_27 AC 252 ms
91,648 KB
testcase_28 AC 252 ms
91,264 KB
testcase_29 AC 250 ms
91,136 KB
testcase_30 AC 43 ms
52,096 KB
testcase_31 AC 116 ms
90,368 KB
testcase_32 AC 117 ms
89,856 KB
testcase_33 AC 116 ms
91,776 KB
testcase_34 AC 43 ms
52,352 KB
testcase_35 AC 43 ms
52,480 KB
testcase_36 AC 42 ms
52,096 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from heapq import heapify, heappush, heappop
import sys
def main():
    input = sys.stdin.readline
    N, X, Y, Z = map(int, input().split())
    *A, = map(lambda x: -int(x), input().split())
    heapify(A)
    cnt = [Z, Y, X]
    for c, n in enumerate([10000, 5000, 1000]):
        while A and cnt[c] > 0:
            p = -heappop(A)
            d, m = divmod(p + 1, n)
            if d == 0 or (d == 1 and m == 0):
                cnt[c] -= 1
                continue
            if m == 0: d -= 1
            d = min(d, cnt[c])
            heappush(A, n * d - p)
            cnt[c] -= d
    print('No' if A else 'Yes')

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