結果

問題 No.914 Omiyage
ユーザー convexineqconvexineq
提出日時 2019-10-25 21:28:43
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 43 ms / 2,000 ms
コード長 562 bytes
コンパイル時間 77 ms
コンパイル使用メモリ 11,936 KB
実行使用メモリ 10,104 KB
最終ジャッジ日時 2023-10-24 21:09:53
合計ジャッジ時間 1,542 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
10,104 KB
testcase_01 AC 36 ms
10,104 KB
testcase_02 AC 31 ms
10,104 KB
testcase_03 AC 38 ms
10,104 KB
testcase_04 AC 30 ms
10,104 KB
testcase_05 AC 29 ms
10,104 KB
testcase_06 AC 29 ms
10,104 KB
testcase_07 AC 29 ms
10,104 KB
testcase_08 AC 29 ms
10,104 KB
testcase_09 AC 29 ms
10,104 KB
testcase_10 AC 34 ms
10,104 KB
testcase_11 AC 32 ms
10,104 KB
testcase_12 AC 37 ms
10,104 KB
testcase_13 AC 33 ms
10,104 KB
testcase_14 AC 38 ms
10,104 KB
testcase_15 AC 31 ms
10,104 KB
testcase_16 AC 31 ms
10,104 KB
testcase_17 AC 36 ms
10,104 KB
testcase_18 AC 30 ms
10,104 KB
testcase_19 AC 29 ms
10,104 KB
testcase_20 AC 29 ms
10,104 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# coding: utf-8
# Your code here!

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline 

n,m,k = [int(i) for i in readline().split()]


dp = [0]*(501)
dp[k] = 1

m = 0
for i in range(n):
    a = [int(i) for i in readline().split()]
    m += min(a)
    ndp = [0]*(501)
    for i in range(k+1):
        for ai in a:
            if i >= ai:
                ndp[i-ai] |= dp[i]
    
    dp = ndp
#    print(dp[:20])


if m > k:
    print(-1)
    exit()

for c in range(k):
    if dp[c] == 1:
        print(c)
        break
else:
    print(-1)


    
0