結果

問題 No.914 Omiyage
ユーザー hedwig100hedwig100
提出日時 2020-04-10 14:21:24
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 28 ms / 2,000 ms
コード長 708 bytes
コンパイル時間 157 ms
コンパイル使用メモリ 10,804 KB
実行使用メモリ 8,704 KB
最終ジャッジ日時 2023-10-13 03:44:49
合計ジャッジ時間 1,919 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
8,588 KB
testcase_01 AC 22 ms
8,520 KB
testcase_02 AC 19 ms
8,544 KB
testcase_03 AC 26 ms
8,704 KB
testcase_04 AC 19 ms
8,532 KB
testcase_05 AC 19 ms
8,680 KB
testcase_06 AC 19 ms
8,500 KB
testcase_07 AC 19 ms
8,704 KB
testcase_08 AC 19 ms
8,540 KB
testcase_09 AC 19 ms
8,576 KB
testcase_10 AC 23 ms
8,564 KB
testcase_11 AC 21 ms
8,620 KB
testcase_12 AC 25 ms
8,616 KB
testcase_13 AC 21 ms
8,684 KB
testcase_14 AC 25 ms
8,684 KB
testcase_15 AC 20 ms
8,496 KB
testcase_16 AC 21 ms
8,660 KB
testcase_17 AC 24 ms
8,696 KB
testcase_18 AC 19 ms
8,540 KB
testcase_19 AC 19 ms
8,660 KB
testcase_20 AC 19 ms
8,496 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 10 ** 9 + 7
INF = 10 ** 10
import sys
sys.setrecursionlimit(100000000)
dy = (-1,0,1,0)
dx = (0,1,0,-1)
from collections import deque
from heapq import heapify,heappush,heappop

def main():
    n,m,k = map(int,input().split())
    a = [list(map(int,input().split())) for _ in range(n)]

    dp = [[0] * (k + 1) for _ in range(n + 1)]
    dp[0][k] = 1
    for i in range(n):
        for money in range(k + 1):
            for j in range(m):
                if money + a[i][j] < k + 1:
                    dp[i + 1][money] |= dp[i][money + a[i][j]]
    
    ans = -1
    for i in range(k):
        if dp[-1][i]:
            ans = i
            break
    print(ans)

if __name__ =='__main__':
    main()  
0