結果

問題 No.825 賢いお買い物
ユーザー YCescaYCesca
提出日時 2019-05-04 05:08:04
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 18 ms / 2,000 ms
コード長 1,017 bytes
コンパイル時間 605 ms
コンパイル使用メモリ 10,952 KB
実行使用メモリ 8,328 KB
最終ジャッジ日時 2023-09-02 01:00:30
合計ジャッジ時間 1,657 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
8,192 KB
testcase_01 AC 16 ms
8,240 KB
testcase_02 AC 15 ms
8,188 KB
testcase_03 AC 18 ms
8,240 KB
testcase_04 AC 15 ms
8,184 KB
testcase_05 AC 16 ms
8,180 KB
testcase_06 AC 14 ms
8,164 KB
testcase_07 AC 15 ms
8,172 KB
testcase_08 AC 15 ms
8,196 KB
testcase_09 AC 15 ms
7,836 KB
testcase_10 AC 15 ms
8,200 KB
testcase_11 AC 14 ms
8,328 KB
testcase_12 AC 14 ms
8,304 KB
testcase_13 AC 13 ms
8,180 KB
testcase_14 AC 15 ms
8,200 KB
testcase_15 AC 15 ms
8,284 KB
testcase_16 AC 15 ms
8,156 KB
testcase_17 AC 15 ms
8,176 KB
testcase_18 AC 16 ms
7,768 KB
testcase_19 AC 15 ms
8,200 KB
testcase_20 AC 14 ms
8,248 KB
testcase_21 AC 15 ms
8,292 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

a,b,c=map(int,input().split())

def get_price(i: int) ->int:
  price = (10 * b + a) - (10 * (c-i) + i) 
  return price

# index= = 購入後のaの値 となる 買った商品の購入額のリスト
plist=[0]*(c+1)

if a+b < c:
  pind=0
  for i in range(c+1):
    plist[i]=get_price(i)
    if plist[i] <= 0:
      pind=i
  if plist[pind] <= 0 and pind < c:
    pind+=1
#途中で正に変わる場合の仕掛け
#チェックが必要
#変化後のa=pind 変化後のb=c-pind
  price=plist[pind]
  
  checka=a
  checkb=b
  defb=b-(c-pind)
  checkb=c-pind
  temp=10 * defb - price
  checka+=temp%10
  if b != 0:
    checkb+=temp//b

  if max(plist) <= 0:
    print("Impossible")
  elif (checka == pind and checkb == c-pind):
    print(price)
  else:
    print("Impossible")

else:
  pind=0
  for i in range(c+1):
    plist[i]=get_price(i)
    if plist[i] <= 0:
      pind=i
  if plist[pind] <= 0 and pind < c:
    pind+=1  
  price=plist[pind]
    
  if price <= 0 :
    print("Impossible")
  else:
    print(price)
0