結果

問題 No.1015 おつりは要らないです
ユーザー FromBooskaFromBooska
提出日時 2023-10-17 12:27:51
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 117 ms / 2,000 ms
コード長 1,731 bytes
コンパイル時間 168 ms
コンパイル使用メモリ 81,808 KB
実行使用メモリ 91,728 KB
最終ジャッジ日時 2023-10-17 12:27:56
合計ジャッジ時間 5,155 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
53,420 KB
testcase_01 AC 40 ms
53,420 KB
testcase_02 AC 38 ms
53,420 KB
testcase_03 AC 39 ms
53,420 KB
testcase_04 AC 38 ms
53,420 KB
testcase_05 AC 39 ms
53,420 KB
testcase_06 AC 39 ms
53,420 KB
testcase_07 AC 40 ms
53,420 KB
testcase_08 AC 38 ms
53,420 KB
testcase_09 AC 38 ms
53,420 KB
testcase_10 AC 115 ms
91,608 KB
testcase_11 AC 114 ms
91,416 KB
testcase_12 AC 113 ms
91,512 KB
testcase_13 AC 114 ms
91,356 KB
testcase_14 AC 115 ms
91,728 KB
testcase_15 AC 112 ms
91,536 KB
testcase_16 AC 116 ms
91,344 KB
testcase_17 AC 117 ms
91,416 KB
testcase_18 AC 117 ms
91,596 KB
testcase_19 AC 114 ms
91,320 KB
testcase_20 AC 106 ms
91,140 KB
testcase_21 AC 106 ms
90,848 KB
testcase_22 AC 104 ms
91,116 KB
testcase_23 AC 100 ms
89,668 KB
testcase_24 AC 107 ms
91,164 KB
testcase_25 AC 105 ms
91,116 KB
testcase_26 AC 104 ms
90,852 KB
testcase_27 AC 105 ms
91,092 KB
testcase_28 AC 105 ms
90,812 KB
testcase_29 AC 108 ms
91,128 KB
testcase_30 AC 38 ms
53,420 KB
testcase_31 AC 68 ms
82,084 KB
testcase_32 AC 68 ms
82,084 KB
testcase_33 AC 92 ms
91,312 KB
testcase_34 AC 38 ms
53,420 KB
testcase_35 AC 38 ms
53,420 KB
testcase_36 AC 38 ms
53,420 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# dpのように見えるが貪欲法、札降順で決めていく
# ぴったり金額では足らないのでa+1しておく
# すべての1万以上の商品に、1万未満となるまで、1万円札を使う、余れば商品価格降順で使い切る
# 次に5千円札、1千円札
# チャレンジケースで1RE、Z_remainderがNより大きければエラーだな

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(min(N, 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(min(N, 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(min(N, 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