結果

問題 No.914 Omiyage
ユーザー H3PO4H3PO4
提出日時 2021-05-06 10:08:19
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 137 ms / 2,000 ms
コード長 342 bytes
コンパイル時間 101 ms
コンパイル使用メモリ 10,708 KB
実行使用メモリ 29,668 KB
最終ジャッジ日時 2023-10-12 03:24:27
合計ジャッジ時間 6,922 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 134 ms
29,600 KB
testcase_01 AC 128 ms
29,592 KB
testcase_02 AC 127 ms
29,668 KB
testcase_03 AC 129 ms
29,632 KB
testcase_04 AC 129 ms
29,600 KB
testcase_05 AC 128 ms
29,580 KB
testcase_06 AC 129 ms
29,624 KB
testcase_07 AC 132 ms
29,620 KB
testcase_08 AC 133 ms
29,524 KB
testcase_09 AC 133 ms
29,548 KB
testcase_10 AC 134 ms
29,632 KB
testcase_11 AC 133 ms
29,560 KB
testcase_12 AC 133 ms
29,628 KB
testcase_13 AC 131 ms
29,600 KB
testcase_14 AC 128 ms
29,548 KB
testcase_15 AC 128 ms
29,540 KB
testcase_16 AC 129 ms
29,624 KB
testcase_17 AC 132 ms
29,560 KB
testcase_18 AC 127 ms
29,624 KB
testcase_19 AC 137 ms
29,600 KB
testcase_20 AC 137 ms
29,512 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import numpy as np

N, M, K = map(int, input().split())
dp = np.zeros(K + 1, dtype=bool)
dp[K] = True

for _ in range(N):
    A = map(int, input().split())
    new_dp = np.zeros(K + 1, dtype=bool)
    for a in A:
        new_dp[:-a] |= dp[a:]
    dp = new_dp
    if not np.any(dp):
        print(-1)
        exit()

print(dp.nonzero()[0][0])
0