結果

問題 No.825 賢いお買い物
ユーザー greenteabiscuitgreenteabiscuit
提出日時 2019-05-13 15:56:26
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 745 bytes
コンパイル時間 146 ms
コンパイル使用メモリ 10,852 KB
実行使用メモリ 8,340 KB
最終ジャッジ日時 2023-09-22 01:48:44
合計ジャッジ時間 1,726 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
8,184 KB
testcase_01 AC 40 ms
8,340 KB
testcase_02 AC 20 ms
8,120 KB
testcase_03 AC 17 ms
8,192 KB
testcase_04 AC 19 ms
8,092 KB
testcase_05 AC 23 ms
8,172 KB
testcase_06 AC 16 ms
8,256 KB
testcase_07 AC 17 ms
8,216 KB
testcase_08 AC 27 ms
8,136 KB
testcase_09 AC 17 ms
8,164 KB
testcase_10 AC 21 ms
8,144 KB
testcase_11 AC 26 ms
8,132 KB
testcase_12 AC 19 ms
8,264 KB
testcase_13 AC 16 ms
8,240 KB
testcase_14 AC 17 ms
8,264 KB
testcase_15 AC 23 ms
8,220 KB
testcase_16 AC 25 ms
8,132 KB
testcase_17 AC 17 ms
8,152 KB
testcase_18 WA -
testcase_19 AC 18 ms
8,136 KB
testcase_20 AC 16 ms
8,112 KB
testcase_21 AC 16 ms
8,188 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import product
def func(pay, price, A, B, C):
    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