結果

問題 No.914 Omiyage
ユーザー kurimupykurimupy
提出日時 2020-06-18 01:47:29
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 30 ms / 2,000 ms
コード長 647 bytes
コンパイル時間 201 ms
コンパイル使用メモリ 10,872 KB
実行使用メモリ 7,924 KB
最終ジャッジ日時 2023-09-16 11:51:23
合計ジャッジ時間 1,844 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
7,736 KB
testcase_01 AC 29 ms
7,780 KB
testcase_02 AC 30 ms
7,760 KB
testcase_03 AC 29 ms
7,820 KB
testcase_04 AC 29 ms
7,796 KB
testcase_05 AC 17 ms
7,764 KB
testcase_06 AC 17 ms
7,784 KB
testcase_07 AC 16 ms
7,924 KB
testcase_08 AC 19 ms
7,784 KB
testcase_09 AC 16 ms
7,924 KB
testcase_10 AC 21 ms
7,760 KB
testcase_11 AC 18 ms
7,864 KB
testcase_12 AC 22 ms
7,804 KB
testcase_13 AC 28 ms
7,912 KB
testcase_14 AC 28 ms
7,756 KB
testcase_15 AC 19 ms
7,888 KB
testcase_16 AC 17 ms
7,812 KB
testcase_17 AC 24 ms
7,792 KB
testcase_18 AC 16 ms
7,764 KB
testcase_19 AC 17 ms
7,924 KB
testcase_20 AC 17 ms
7,884 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#テストコード
# yukicoder problem solving
import sys
input=lambda: sys.stdin.readline().rstrip()
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