結果

問題 No.825 賢いお買い物
ユーザー ゆるくゆるく
提出日時 2019-05-03 21:49:44
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 658 bytes
コンパイル時間 518 ms
コンパイル使用メモリ 10,824 KB
実行使用メモリ 56,756 KB
最終ジャッジ日時 2023-08-30 06:04:54
合計ジャッジ時間 4,268 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
14,780 KB
testcase_01 AC 33 ms
10,468 KB
testcase_02 AC 31 ms
10,232 KB
testcase_03 AC 31 ms
10,396 KB
testcase_04 AC 30 ms
10,392 KB
testcase_05 WA -
testcase_06 AC 31 ms
10,340 KB
testcase_07 AC 31 ms
10,328 KB
testcase_08 TLE -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

a, b, c = map(int, input().split())
ans = []
def dfs(x, y, pay):
    if x + y == c:
        ans.append(pay)
    if x + y < c:
        return -1
    if y > 0:
        dfs(x, y - 1, pay + 10)
    if x >= 10:
        dfs(x - 10, y + 1, pay)
    if x > 0:
        dfs(x - 1, y, pay + 1)
    return -1

if a + b == c:
    print('Impossible')
else:
    dfs(a, b, 0)
    if ans:
        print(min(ans))
    else:
        print('Impossible')
0