結果

問題 No.2681 ゲームセンターの両替
ユーザー 👑 tipstar0125tipstar0125
提出日時 2024-03-20 22:09:54
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 56 ms / 2,000 ms
コード長 538 bytes
コンパイル時間 173 ms
コンパイル使用メモリ 82,204 KB
実行使用メモリ 60,372 KB
最終ジャッジ日時 2024-04-15 10:13:23
合計ジャッジ時間 2,514 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 51 ms
53,880 KB
testcase_01 AC 51 ms
53,820 KB
testcase_02 AC 50 ms
53,628 KB
testcase_03 AC 51 ms
55,000 KB
testcase_04 AC 54 ms
60,372 KB
testcase_05 AC 55 ms
53,700 KB
testcase_06 AC 55 ms
59,560 KB
testcase_07 AC 54 ms
59,500 KB
testcase_08 AC 56 ms
59,744 KB
testcase_09 AC 55 ms
59,432 KB
testcase_10 AC 50 ms
54,796 KB
testcase_11 AC 55 ms
60,288 KB
testcase_12 AC 50 ms
53,884 KB
testcase_13 AC 51 ms
53,928 KB
testcase_14 AC 54 ms
54,684 KB
testcase_15 AC 48 ms
53,776 KB
testcase_16 AC 51 ms
54,368 KB
testcase_17 AC 52 ms
54,080 KB
testcase_18 AC 52 ms
54,704 KB
testcase_19 AC 51 ms
54,072 KB
testcase_20 AC 50 ms
55,300 KB
testcase_21 AC 49 ms
53,536 KB
testcase_22 AC 56 ms
58,884 KB
testcase_23 AC 51 ms
53,628 KB
testcase_24 AC 51 ms
55,220 KB
testcase_25 AC 51 ms
54,244 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
C,Y=list(map(int,input().split()))
coin=[1,5,10,50,100,500,1000,2000,5000,10000]
L=len(coin)

cnt=defaultdict(int)
for i in range(L-1,-1,-1):
    cnt[coin[i]]=Y//coin[i]
    Y-=cnt[coin[i]]*coin[i]

if cnt[100]>=C:
    print("no exchange")
    exit(0)

can_exchange_money=0
for (k,v) in cnt.items():
    if k>100:can_exchange_money+=k*v
if cnt[100]+can_exchange_money//100<C:
    print("can't exchange")
    exit(0)
ans=cnt[100]
while True:
    ans+=5
    if ans>=C:
        print(ans)
        exit(0)
0