結果

問題 No.914 Omiyage
ユーザー ireenaireena
提出日時 2022-01-23 13:35:42
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 81 ms / 2,000 ms
コード長 395 bytes
コンパイル時間 789 ms
コンパイル使用メモリ 86,776 KB
実行使用メモリ 76,304 KB
最終ジャッジ日時 2023-08-19 18:19:58
合計ジャッジ時間 4,075 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
75,960 KB
testcase_01 AC 81 ms
75,920 KB
testcase_02 AC 77 ms
76,304 KB
testcase_03 AC 80 ms
75,928 KB
testcase_04 AC 79 ms
75,888 KB
testcase_05 AC 73 ms
71,028 KB
testcase_06 AC 71 ms
71,124 KB
testcase_07 AC 72 ms
71,116 KB
testcase_08 AC 72 ms
71,280 KB
testcase_09 AC 73 ms
71,360 KB
testcase_10 AC 81 ms
75,832 KB
testcase_11 AC 79 ms
76,000 KB
testcase_12 AC 80 ms
75,968 KB
testcase_13 AC 81 ms
75,908 KB
testcase_14 AC 80 ms
75,952 KB
testcase_15 AC 77 ms
75,996 KB
testcase_16 AC 76 ms
75,960 KB
testcase_17 AC 79 ms
76,028 KB
testcase_18 AC 72 ms
71,188 KB
testcase_19 AC 72 ms
71,188 KB
testcase_20 AC 72 ms
71,028 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, M, K = map(int, input().split())

A = [list(map(int, input().split())) for _ in range(N)]

dp = [False] * (K+1)
dp[0] = True

for i in range(N):
    nx = [False] * (K+1)
    for a in A[i]:
        for j in range(K+1):
            if j + a > K:
                break
            nx[j+a] |= dp[j]
    dp = nx

for i in range(K+1)[::-1]:
    if dp[i]:
        print(K-i)
        exit()
print(-1)
0