結果

問題 No.5 数字のブロック
ユーザー kaminomisosirukaminomisosiru
提出日時 2018-02-04 15:00:30
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
MLE  
実行時間 -
コード長 530 bytes
コンパイル時間 78 ms
コンパイル使用メモリ 10,964 KB
実行使用メモリ 815,528 KB
最終ジャッジ日時 2023-09-12 16:01:22
合計ジャッジ時間 15,158 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 MLE -
testcase_01 MLE -
testcase_02 MLE -
testcase_03 MLE -
testcase_04 MLE -
testcase_05 MLE -
testcase_06 MLE -
testcase_07 MLE -
testcase_08 MLE -
testcase_09 MLE -
testcase_10 MLE -
testcase_11 MLE -
testcase_12 MLE -
testcase_13 MLE -
testcase_14 MLE -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

# coding: utf-8

import numpy as np

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

MAX_N,MAX_L = 10000,10000
memo = -1*np.ones((MAX_N+1,MAX_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
        print(memo)

        return res

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