結果

問題 No.914 Omiyage
ユーザー Chihaya_chanChihaya_chan
提出日時 2020-06-13 14:22:34
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 26 ms / 2,000 ms
コード長 572 bytes
コンパイル時間 80 ms
コンパイル使用メモリ 10,900 KB
実行使用メモリ 7,952 KB
最終ジャッジ日時 2023-09-07 09:12:08
合計ジャッジ時間 2,315 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
7,868 KB
testcase_01 AC 25 ms
7,900 KB
testcase_02 AC 25 ms
7,900 KB
testcase_03 AC 25 ms
7,900 KB
testcase_04 AC 24 ms
7,760 KB
testcase_05 AC 13 ms
7,768 KB
testcase_06 AC 12 ms
7,792 KB
testcase_07 AC 13 ms
7,940 KB
testcase_08 AC 16 ms
7,880 KB
testcase_09 AC 13 ms
7,772 KB
testcase_10 AC 17 ms
7,884 KB
testcase_11 AC 15 ms
7,940 KB
testcase_12 AC 19 ms
7,896 KB
testcase_13 AC 23 ms
7,868 KB
testcase_14 AC 24 ms
7,804 KB
testcase_15 AC 16 ms
7,792 KB
testcase_16 AC 14 ms
7,752 KB
testcase_17 AC 19 ms
7,952 KB
testcase_18 AC 13 ms
7,816 KB
testcase_19 AC 13 ms
7,948 KB
testcase_20 AC 14 ms
7,712 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