結果

問題 No.825 賢いお買い物
ユーザー greenteabiscuit
提出日時 2019-05-13 15:51:29
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
RE  
実行時間 -
コード長 738 bytes
コンパイル時間 211 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-07-07 18:34:55
合計ジャッジ時間 1,831 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample RE * 3
other RE * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

def func(pay, price, A, B, C):
    #pay: a, b
    change = pay[0] + 10 * pay[1] - price
    if change < 0:
        return None
    else:
        one_coin = (change) % 10
        ten_coin = (change) // 10
        coins = A - pay[0] + one_coin + B - pay[1] + ten_coin

        if coins == C:
            return price       
        else:
            return None
    
A, B, C = map(int, input().split(' '))
num_list_A = [i for i in range(A + 1)]
num_list_B = [i for i in range(B + 1)]
pay_combos = list(product(num_list_A, num_list_B))

price = [func(pay, price, A, B, C) for pay in pay_combos for price in range(1, A + B * 10) if func(pay, price, A, B, C) is not None]
if not price:
    print('Impossible')
else:
    print(sorted(price)[0])
0