結果

問題 No.914 Omiyage
ユーザー ayaoniayaoni
提出日時 2020-12-09 23:58:13
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 49 ms / 2,000 ms
コード長 821 bytes
コンパイル時間 161 ms
コンパイル使用メモリ 81,624 KB
実行使用メモリ 61,848 KB
最終ジャッジ日時 2023-10-19 10:16:51
合計ジャッジ時間 1,910 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 49 ms
61,772 KB
testcase_01 AC 49 ms
61,780 KB
testcase_02 AC 44 ms
59,492 KB
testcase_03 AC 48 ms
61,836 KB
testcase_04 AC 44 ms
59,568 KB
testcase_05 AC 38 ms
53,440 KB
testcase_06 AC 39 ms
53,440 KB
testcase_07 AC 40 ms
53,440 KB
testcase_08 AC 41 ms
53,440 KB
testcase_09 AC 39 ms
53,440 KB
testcase_10 AC 43 ms
59,312 KB
testcase_11 AC 42 ms
59,312 KB
testcase_12 AC 45 ms
59,712 KB
testcase_13 AC 49 ms
59,720 KB
testcase_14 AC 49 ms
61,848 KB
testcase_15 AC 44 ms
59,432 KB
testcase_16 AC 40 ms
53,440 KB
testcase_17 AC 47 ms
59,712 KB
testcase_18 AC 39 ms
53,440 KB
testcase_19 AC 40 ms
53,440 KB
testcase_20 AC 39 ms
53,440 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def LS2(): return list(sys.stdin.readline().rstrip())


N,M,K = MI()
A = [None]+[LI() for _ in range(N)]

flag = [[0]*(K+1) for _ in range(N+1)]
flag[0][0] = 1
for i in range(1,N+1):
    for j in range(K+1):
        if flag[i-1][j]:
            for a in A[i]:
                if j+a <= K:
                    flag[i][j+a] = 1

for i in range(K,-1,-1):
    if flag[-1][i]:
        print(K-i)
        break
else:
    print(-1)
0