結果

問題 No.5 数字のブロック
ユーザー kaminomisosirukaminomisosiru
提出日時 2018-02-04 14:45:23
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 472 bytes
コンパイル時間 148 ms
コンパイル使用メモリ 10,880 KB
実行使用メモリ 812,284 KB
最終ジャッジ日時 2023-09-12 15:59:58
合計ジャッジ時間 12,825 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 131 ms
29,380 KB
testcase_01 AC 134 ms
29,132 KB
testcase_02 AC 131 ms
29,196 KB
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 AC 696 ms
37,816 KB
testcase_15 AC 181 ms
30,188 KB
testcase_16 RE -
testcase_17 MLE -
testcase_18 RE -
testcase_19 MLE -
testcase_20 AC 177 ms
29,544 KB
testcase_21 AC 130 ms
29,216 KB
testcase_22 AC 131 ms
29,188 KB
testcase_23 AC 129 ms
29,212 KB
testcase_24 AC 256 ms
31,128 KB
testcase_25 AC 3,703 ms
63,696 KB
testcase_26 AC 129 ms
29,216 KB
testcase_27 AC 131 ms
29,172 KB
testcase_28 AC 131 ms
29,540 KB
testcase_29 RE -
testcase_30 RE -
testcase_31 AC 129 ms
29,508 KB
testcase_32 AC 130 ms
29,492 KB
testcase_33 AC 131 ms
29,148 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# coding: utf-8

import numpy as np

L = int(input())
N = int(input())
length = [int(i) for i in input().split()]

memo = -1*np.ones((N+1,L+1))

def search(i,j):
    if memo[i,j] != -1:
        return memo[i,j]
    else:
        if i == N:
            res = 0
        elif j < length[i]:
            res = search(i+1,j)
        else:
            res = max(search(i+1, j), search(i+1, j - length[i]) + 1)
        memo[i,j] = res

        return res

print(int(search(0,L)))
0