結果

問題 No.914 Omiyage
ユーザー roarisroaris
提出日時 2019-10-25 21:29:47
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 52 ms / 2,000 ms
コード長 398 bytes
コンパイル時間 161 ms
コンパイル使用メモリ 81,588 KB
実行使用メモリ 61,824 KB
最終ジャッジ日時 2023-10-24 21:10:52
合計ジャッジ時間 1,904 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 52 ms
61,824 KB
testcase_01 AC 51 ms
61,812 KB
testcase_02 AC 47 ms
61,772 KB
testcase_03 AC 51 ms
61,824 KB
testcase_04 AC 47 ms
61,780 KB
testcase_05 AC 39 ms
53,312 KB
testcase_06 AC 38 ms
53,312 KB
testcase_07 AC 38 ms
53,312 KB
testcase_08 AC 43 ms
59,564 KB
testcase_09 AC 38 ms
53,312 KB
testcase_10 AC 49 ms
61,808 KB
testcase_11 AC 48 ms
61,788 KB
testcase_12 AC 50 ms
61,808 KB
testcase_13 AC 50 ms
61,812 KB
testcase_14 AC 50 ms
61,812 KB
testcase_15 AC 49 ms
61,808 KB
testcase_16 AC 45 ms
59,728 KB
testcase_17 AC 51 ms
61,824 KB
testcase_18 AC 38 ms
53,312 KB
testcase_19 AC 38 ms
53,312 KB
testcase_20 AC 38 ms
53,312 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, M, K = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(N)]
dp = [[False] * (K+1) for _ in range(N+1)]
dp[0][0] = True

for i in range(N):
    for j in range(M):
        for k in range(K+1):
            if k-A[i][j] >= 0:
                dp[i+1][k] |= dp[i][k-A[i][j]]

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