結果

問題 No.914 Omiyage
ユーザー yassu0320yassu0320
提出日時 2021-07-11 13:54:50
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 170 ms / 2,000 ms
コード長 1,282 bytes
コンパイル時間 260 ms
コンパイル使用メモリ 86,856 KB
実行使用メモリ 81,776 KB
最終ジャッジ日時 2023-09-14 20:09:30
合計ジャッジ時間 5,684 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 164 ms
81,776 KB
testcase_01 AC 170 ms
81,596 KB
testcase_02 AC 160 ms
81,004 KB
testcase_03 AC 164 ms
81,556 KB
testcase_04 AC 163 ms
81,020 KB
testcase_05 AC 158 ms
80,020 KB
testcase_06 AC 159 ms
80,068 KB
testcase_07 AC 156 ms
80,220 KB
testcase_08 AC 159 ms
81,048 KB
testcase_09 AC 157 ms
80,256 KB
testcase_10 AC 164 ms
81,112 KB
testcase_11 AC 162 ms
81,004 KB
testcase_12 AC 164 ms
81,048 KB
testcase_13 AC 170 ms
81,408 KB
testcase_14 AC 168 ms
81,312 KB
testcase_15 AC 163 ms
80,828 KB
testcase_16 AC 162 ms
81,052 KB
testcase_17 AC 164 ms
81,044 KB
testcase_18 AC 158 ms
79,984 KB
testcase_19 AC 160 ms
80,036 KB
testcase_20 AC 162 ms
80,000 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3

from sys import setrecursionlimit, stdin
from typing import Dict, Iterable, Set

INF: int = 2**62
MOD: int = 10**9 + 7

setrecursionlimit(10**6)


def inputs(type_=int):
    ins = input().split(' ')
    ins = [x for x in ins if x != '']

    if isinstance(type_, Iterable):
        return [t(x) for t, x in zip(type_, ins)]
    else:
        return list(map(type_, ins))


def input_(type_=int):
    a, = inputs(type_)
    return a


inputi = input_


def inputstr():
    return input_(str)


# b/aの切り上げ
def ceil(b, a):
    return (a + b - 1) // a


def answer(res) -> None:
    print(res)
    exit()


def compute():
    return


def main():
    n, m, k = inputs()
    xs = [None for _ in range(n)]
    for i in range(n):
        xs[i] = inputs()

    xs = [[0] * m] + xs
    n += 1

    dp = [[False] * (k + 1) for _ in range(n)]
    dp[0][0] = True
    for i in range(1, n):
        for j in range(k + 1):
            for s in range(m):
                if dp[i-1][j] and j + xs[i][s] <= k:
                    dp[i][j + xs[i][s]] = True

    # from pprint import pprint
    # pprint(dp)
    for j in reversed(range(k + 1)):
        if dp[-1][j]:
            print(k - j)
            exit()

    print(-1)


if __name__ == '__main__':
    main()
0