結果

問題 No.2681 ゲームセンターの両替
ユーザー shobonvipshobonvip
提出日時 2024-03-20 21:55:31
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 47 ms / 2,000 ms
コード長 432 bytes
コンパイル時間 158 ms
コンパイル使用メモリ 82,828 KB
実行使用メモリ 59,700 KB
最終ジャッジ日時 2024-04-15 10:13:19
合計ジャッジ時間 2,093 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
52,380 KB
testcase_01 AC 38 ms
52,944 KB
testcase_02 AC 38 ms
51,956 KB
testcase_03 AC 43 ms
59,700 KB
testcase_04 AC 43 ms
59,176 KB
testcase_05 AC 44 ms
58,224 KB
testcase_06 AC 45 ms
58,684 KB
testcase_07 AC 47 ms
58,264 KB
testcase_08 AC 44 ms
57,948 KB
testcase_09 AC 44 ms
58,300 KB
testcase_10 AC 44 ms
59,696 KB
testcase_11 AC 43 ms
59,044 KB
testcase_12 AC 39 ms
52,056 KB
testcase_13 AC 39 ms
52,904 KB
testcase_14 AC 41 ms
52,660 KB
testcase_15 AC 39 ms
53,404 KB
testcase_16 AC 41 ms
52,548 KB
testcase_17 AC 39 ms
52,968 KB
testcase_18 AC 39 ms
52,752 KB
testcase_19 AC 39 ms
52,348 KB
testcase_20 AC 40 ms
51,992 KB
testcase_21 AC 40 ms
51,828 KB
testcase_22 AC 44 ms
58,188 KB
testcase_23 AC 39 ms
52,600 KB
testcase_24 AC 40 ms
51,748 KB
testcase_25 AC 39 ms
52,216 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

c, y = map(int,input().split())

a = [1, 5, 10, 50, 100, 500, 1000, 2000, 5000, 10000]
b = [0] * len(a)

for i in range(len(a)-1,-1,-1):
	t = y // a[i]
	b[i] += t
	y %= a[i]

if b[4] >= c:
	print("no exchange")
	exit()

cnt = 0
piv = len(a) - 1
g = b[4]%5
while b[4] < c:
	if piv == 4:
		print("can't exchange")
		exit()
	if b[piv] == 0:
		piv -= 1
		continue
	b[4] += a[piv] // 100
	b[piv] -= 1
	cnt += 1

print(g + ((c-g+4)//5)*5)
0