結果

問題 No.914 Omiyage
ユーザー ronpooronpoo
提出日時 2023-08-25 15:38:59
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 98 ms / 2,000 ms
コード長 463 bytes
コンパイル時間 262 ms
コンパイル使用メモリ 87,300 KB
実行使用メモリ 76,156 KB
最終ジャッジ日時 2023-08-25 15:39:03
合計ジャッジ時間 3,072 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
75,904 KB
testcase_01 AC 74 ms
75,828 KB
testcase_02 AC 74 ms
76,036 KB
testcase_03 AC 79 ms
76,112 KB
testcase_04 AC 77 ms
75,512 KB
testcase_05 AC 69 ms
71,188 KB
testcase_06 AC 68 ms
71,100 KB
testcase_07 AC 68 ms
70,972 KB
testcase_08 AC 68 ms
71,120 KB
testcase_09 AC 69 ms
70,728 KB
testcase_10 AC 74 ms
75,680 KB
testcase_11 AC 72 ms
75,204 KB
testcase_12 AC 78 ms
76,104 KB
testcase_13 AC 75 ms
75,736 KB
testcase_14 AC 78 ms
76,156 KB
testcase_15 AC 98 ms
75,672 KB
testcase_16 AC 69 ms
70,864 KB
testcase_17 AC 79 ms
75,980 KB
testcase_18 AC 70 ms
70,728 KB
testcase_19 AC 68 ms
71,116 KB
testcase_20 AC 69 ms
71,068 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

dp = [-1] * (K+1)
dp[0] = 0
for i in range(N):
    for j in range(K, -1, -1):
        if dp[j] == -1:
            continue
        for k in range(M):
            v = j + A[i][k]
            if v <= K:
                dp[v] = max(dp[v], dp[j] + 1)
            
for i in range(K, -1, -1):
    if dp[i] == N:
        ans = K - i
        break
else:
    ans = -1
print(ans)
0