結果

問題 No.825 賢いお買い物
ユーザー hang_hang_clnhang_hang_cln
提出日時 2019-05-27 21:04:51
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 31 ms / 2,000 ms
コード長 563 bytes
コンパイル時間 78 ms
コンパイル使用メモリ 11,920 KB
実行使用メモリ 10,240 KB
最終ジャッジ日時 2023-10-17 18:18:00
合計ジャッジ時間 1,663 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
10,240 KB
testcase_01 AC 29 ms
10,240 KB
testcase_02 AC 29 ms
10,240 KB
testcase_03 AC 29 ms
10,240 KB
testcase_04 AC 29 ms
10,240 KB
testcase_05 AC 29 ms
10,240 KB
testcase_06 AC 29 ms
10,240 KB
testcase_07 AC 29 ms
10,240 KB
testcase_08 AC 29 ms
10,240 KB
testcase_09 AC 29 ms
10,240 KB
testcase_10 AC 28 ms
10,240 KB
testcase_11 AC 29 ms
10,240 KB
testcase_12 AC 31 ms
10,240 KB
testcase_13 AC 30 ms
10,240 KB
testcase_14 AC 29 ms
10,240 KB
testcase_15 AC 29 ms
10,240 KB
testcase_16 AC 30 ms
10,240 KB
testcase_17 AC 30 ms
10,240 KB
testcase_18 AC 29 ms
10,240 KB
testcase_19 AC 28 ms
10,240 KB
testcase_20 AC 29 ms
10,240 KB
testcase_21 AC 29 ms
10,240 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.py:10: SyntaxWarning: "is" with a literal. Did you mean "=="?
  elif coins is 0:
Main.py:14: SyntaxWarning: "is" with a literal. Did you mean "=="?
  elif a is 0:

ソースコード

diff #

A, B, C = map(int, input().split())

# 複数回の会計に分割できる
def calc(a,b,coins):
  if coins <= -9:
    return None
  elif coins < 0:
    
    return None if b == 0 else 1 + calc(a+9, b-1, coins+8) # 1Gに対して10G払う。
  elif coins is 0:
    return 0
  elif a >= 11 and coins >= 10:
    return 1 + calc(a-11, b+1, coins-10) # 11枚1G払ってお釣り10Gもらう
  elif a is 0:
    return coins * 10
  else:
    g1 = min(a, coins)
    return g1 + calc(a-g1, b, coins-g1)
      
print(calc(A, B, A+B-C) or "Impossible")
# 9 17 -1
# 18 16 -1
0