結果
| 問題 |
No.825 賢いお買い物
|
| ユーザー |
|
| 提出日時 | 2019-05-21 18:10:17 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 906 bytes |
| コンパイル時間 | 118 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 17,824 KB |
| 最終ジャッジ日時 | 2024-09-17 09:05:07 |
| 合計ジャッジ時間 | 3,813 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 3 |
| other | WA * 5 TLE * 1 -- * 13 |
ソースコード
# increase
# 10 buy 1 +9
# decrease
# 1*10 exchange 10 -9
# if A+B==C and B>0 then 10 buy 9
def same(A, B, diff):
if B > 0:
return 9
return 0
def increase(A, B, diff):
if B == 0:
return 0
if diff > 9:
return 0
return 10-diff
def decrease(A, B, diff):
cnt = 0
while diff < -9:
if A > 9:
A -= 10
B += 1
diff += 9
if diff == 0:
return same(A, B, diff)
if A+diff > 0:
return cnt-diff
cnt += A
diff += A
if B+diff > 0:
return cnt-diff*10
return 0
A, B, C = [int(i) for i in input().split()]
diff = C-A-B
if diff > 0:
price = increase(A, B, diff)
elif diff < 0:
price = decrease(A, B, diff)
else:
price = same(A, B, diff)
if price > 0:
print(price, '\n')
else:
print("Impossible\n")