結果

問題 No.825 賢いお買い物
ユーザー YCescaYCesca
提出日時 2019-05-04 05:02:29
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 969 bytes
コンパイル時間 92 ms
コンパイル使用メモリ 11,068 KB
実行使用メモリ 8,368 KB
最終ジャッジ日時 2023-09-02 00:50:04
合計ジャッジ時間 1,671 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,188 KB
testcase_01 AC 15 ms
8,184 KB
testcase_02 AC 16 ms
8,308 KB
testcase_03 AC 15 ms
8,368 KB
testcase_04 AC 16 ms
8,272 KB
testcase_05 AC 16 ms
8,320 KB
testcase_06 AC 16 ms
8,272 KB
testcase_07 AC 16 ms
8,248 KB
testcase_08 AC 16 ms
8,216 KB
testcase_09 AC 15 ms
8,172 KB
testcase_10 AC 16 ms
8,224 KB
testcase_11 AC 16 ms
8,156 KB
testcase_12 AC 16 ms
7,948 KB
testcase_13 WA -
testcase_14 AC 16 ms
8,184 KB
testcase_15 AC 16 ms
8,316 KB
testcase_16 AC 16 ms
8,312 KB
testcase_17 AC 16 ms
8,256 KB
testcase_18 AC 16 ms
8,176 KB
testcase_19 AC 16 ms
8,252 KB
testcase_20 AC 16 ms
8,244 KB
testcase_21 AC 15 ms
8,212 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 (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