結果

問題 No.914 Omiyage
ユーザー qibqib
提出日時 2023-03-28 21:07:22
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 49 ms / 2,000 ms
コード長 433 bytes
コンパイル時間 324 ms
コンパイル使用メモリ 81,860 KB
実行使用メモリ 62,020 KB
最終ジャッジ日時 2023-10-20 14:11:38
合計ジャッジ時間 2,639 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 48 ms
59,952 KB
testcase_01 AC 48 ms
62,020 KB
testcase_02 AC 40 ms
53,568 KB
testcase_03 AC 49 ms
62,016 KB
testcase_04 AC 44 ms
59,804 KB
testcase_05 AC 39 ms
53,568 KB
testcase_06 AC 41 ms
53,568 KB
testcase_07 AC 39 ms
53,568 KB
testcase_08 AC 40 ms
53,568 KB
testcase_09 AC 39 ms
53,568 KB
testcase_10 AC 43 ms
59,568 KB
testcase_11 AC 43 ms
59,568 KB
testcase_12 AC 47 ms
59,952 KB
testcase_13 AC 47 ms
59,964 KB
testcase_14 AC 49 ms
62,016 KB
testcase_15 AC 44 ms
59,616 KB
testcase_16 AC 40 ms
53,568 KB
testcase_17 AC 47 ms
59,952 KB
testcase_18 AC 39 ms
53,568 KB
testcase_19 AC 39 ms
53,568 KB
testcase_20 AC 39 ms
53,568 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

INF = 1 << 60

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

dp = [False for _ in range(k + 1)]
dp[0] = True
for i in range(n):
  ndp = [False for _ in range(k + 1)]
  for j in range(k):
    if not dp[j]:
      continue
    for diff in a[i]:
      if j + diff <= k:
        ndp[j + diff] = True
  dp = ndp

for j in range(k, -1, -1):
  if dp[j]:
    print(k - j)
    exit()

print("-1")
0