結果

問題 No.914 Omiyage
ユーザー Chihaya_chanChihaya_chan
提出日時 2020-06-13 14:20:24
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 87 ms / 2,000 ms
コード長 572 bytes
コンパイル時間 2,013 ms
コンパイル使用メモリ 86,720 KB
実行使用メモリ 76,132 KB
最終ジャッジ日時 2023-09-07 09:08:25
合計ジャッジ時間 3,466 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 87 ms
75,912 KB
testcase_01 AC 81 ms
75,804 KB
testcase_02 AC 81 ms
76,084 KB
testcase_03 AC 83 ms
75,952 KB
testcase_04 AC 82 ms
75,992 KB
testcase_05 AC 74 ms
75,716 KB
testcase_06 AC 75 ms
75,648 KB
testcase_07 AC 72 ms
71,264 KB
testcase_08 AC 78 ms
75,964 KB
testcase_09 AC 75 ms
71,272 KB
testcase_10 AC 82 ms
75,820 KB
testcase_11 AC 79 ms
75,684 KB
testcase_12 AC 82 ms
76,128 KB
testcase_13 AC 81 ms
76,064 KB
testcase_14 AC 81 ms
76,020 KB
testcase_15 AC 81 ms
75,880 KB
testcase_16 AC 79 ms
75,816 KB
testcase_17 AC 84 ms
76,132 KB
testcase_18 AC 78 ms
75,652 KB
testcase_19 AC 79 ms
75,880 KB
testcase_20 AC 78 ms
75,836 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# yukicoder problem solving
N, M, K = map(int, input().split())
data = [list(map(int, input().split())) for i in range(N)]
dp = [[0 for i in range(501)] for j in range(N+1)]
# dp[P][v] = P番目での買い物を終えて それまでに使った金を v円にできるか。
dp[0][0] = 1
for i in range(N):
    for j in range(M):
        x = data[i][j]
        for k in range(501):
            if k-x >= 0 and dp[i][k-x]:
                dp[i+1][k] = 1
ans = 0
for i in range(K+1):
    if dp[N][i] == 1:
        ans = i
if ans == 0:
    print(-1)
else:
    print(K-ans)
0