結果

問題 No.914 Omiyage
ユーザー yakeshibayakeshiba
提出日時 2021-03-12 01:11:43
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 61 ms / 2,000 ms
コード長 452 bytes
コンパイル時間 300 ms
コンパイル使用メモリ 81,792 KB
実行使用メモリ 60,800 KB
最終ジャッジ日時 2024-04-21 13:13:09
合計ジャッジ時間 2,401 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 57 ms
60,032 KB
testcase_01 AC 57 ms
60,288 KB
testcase_02 AC 56 ms
59,392 KB
testcase_03 AC 58 ms
60,288 KB
testcase_04 AC 56 ms
58,880 KB
testcase_05 AC 47 ms
51,968 KB
testcase_06 AC 47 ms
51,840 KB
testcase_07 AC 47 ms
52,096 KB
testcase_08 AC 53 ms
57,728 KB
testcase_09 AC 47 ms
51,840 KB
testcase_10 AC 58 ms
60,032 KB
testcase_11 AC 57 ms
59,136 KB
testcase_12 AC 61 ms
60,800 KB
testcase_13 AC 60 ms
60,160 KB
testcase_14 AC 61 ms
60,160 KB
testcase_15 AC 59 ms
59,648 KB
testcase_16 AC 54 ms
58,368 KB
testcase_17 AC 61 ms
60,032 KB
testcase_18 AC 48 ms
51,968 KB
testcase_19 AC 47 ms
51,840 KB
testcase_20 AC 48 ms
51,584 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, m, money = map(int,input().split())
A = [0]*n
for i in range(n):
    A[i] = list(map(int,input().split()))
    
dp = [[0]*(money+1) for _ in range(n+1)]
dp[0][0] = 1
for i in range(n):
    for j in range(m):
        for k in range(money):
            if k + A[i][j] <= money and dp[i][k]:
                dp[i+1][k+A[i][j]] = 1
                
for j in range(money, -1, -1):
    if dp[n][j]:
        print(money-j)
        exit()
        
print(-1)
0