結果

問題 No.1015 おつりは要らないです
ユーザー FromBooskaFromBooska
提出日時 2023-10-17 12:23:54
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 1,619 bytes
コンパイル時間 150 ms
コンパイル使用メモリ 81,568 KB
実行使用メモリ 91,500 KB
最終ジャッジ日時 2023-10-17 12:24:00
合計ジャッジ時間 6,028 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
53,200 KB
testcase_01 AC 38 ms
53,200 KB
testcase_02 AC 37 ms
53,200 KB
testcase_03 AC 35 ms
53,200 KB
testcase_04 AC 37 ms
53,200 KB
testcase_05 AC 38 ms
53,200 KB
testcase_06 AC 35 ms
53,200 KB
testcase_07 AC 34 ms
53,200 KB
testcase_08 AC 36 ms
53,200 KB
testcase_09 AC 39 ms
53,200 KB
testcase_10 AC 110 ms
91,376 KB
testcase_11 AC 109 ms
91,188 KB
testcase_12 AC 107 ms
91,280 KB
testcase_13 AC 109 ms
91,124 KB
testcase_14 AC 113 ms
91,500 KB
testcase_15 AC 109 ms
91,304 KB
testcase_16 AC 110 ms
91,376 KB
testcase_17 AC 111 ms
91,188 KB
testcase_18 AC 109 ms
91,364 KB
testcase_19 AC 109 ms
91,232 KB
testcase_20 AC 106 ms
90,908 KB
testcase_21 AC 100 ms
90,616 KB
testcase_22 AC 100 ms
90,884 KB
testcase_23 AC 96 ms
89,428 KB
testcase_24 AC 101 ms
90,932 KB
testcase_25 AC 101 ms
90,884 KB
testcase_26 AC 100 ms
90,620 KB
testcase_27 AC 100 ms
90,740 KB
testcase_28 AC 100 ms
90,580 KB
testcase_29 AC 101 ms
90,896 KB
testcase_30 AC 36 ms
53,200 KB
testcase_31 AC 70 ms
81,852 KB
testcase_32 AC 66 ms
81,852 KB
testcase_33 AC 86 ms
91,080 KB
testcase_34 AC 36 ms
53,200 KB
testcase_35 AC 36 ms
53,200 KB
testcase_36 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

# dpのように見えるが貪欲法、札降順で決めていく
# ぴったり金額では足らないのでa+1しておく
# すべての1万以上の商品に、1万未満となるまで、1万円札を使う、余れば商品価格降順で使い切る
# 次に5千円札、1千円札

N, X, Y, Z = map(int, input().split())
A = list(map(int, input().split()))

A1 = [a+1 for a in A]
# use 10000
Z_remainder = Z
for i in range(N):
    if A1[i] >= 10000:
        howmany = A1[i]//10000
        use = min(howmany, Z_remainder)
        Z_remainder -= use
        A1[i] = max(0, A1[i]-use*10000)
A1.sort(reverse = True)
for i in range(Z_remainder):
    # Z_remainderが1以上なら、残る商品は10000円未満のはず
    A1[i] = max(0, A1[i]-10000)
    Z_remainder -= 1
    
#print(A1, Z_remainder)

# use 5000
Y_remainder = Y
for i in range(N):
    if A1[i] >= 5000:
        howmany = A1[i]//5000
        use = min(howmany, Y_remainder)
        Y_remainder -= use
        A1[i] = max(0, A1[i]-use*5000)
A1.sort(reverse = True)
for i in range(Y_remainder):
    A1[i] = max(0, A1[i]-5000)
    Y_remainder -= 1
    
#print(A1, Y_remainder)

# use 1000
X_remainder = X
for i in range(N):
    if A1[i] >= 1000:
        # 1000のときは繰り上げで使う必要あるだろう
        howmany = (A1[i]+999)//1000
        use = min(howmany, X_remainder)
        X_remainder -= use
        A1[i] = max(0, A1[i]-use*1000)
A1.sort(reverse = True)
for i in range(X_remainder):
    A1[i] = max(0, A1[i]-1000)
    X_remainder -= 1
    
#print(A1, X_remainder)

if sum(A1) == 0:
    print('Yes')
else:
    print('No')
0