結果

問題 No.5 数字のブロック
ユーザー kaminomisosirukaminomisosiru
提出日時 2018-02-04 14:44:27
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 467 bytes
コンパイル時間 277 ms
コンパイル使用メモリ 10,832 KB
実行使用メモリ 810,084 KB
最終ジャッジ日時 2023-09-12 15:59:41
合計ジャッジ時間 17,516 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 130 ms
29,616 KB
testcase_01 WA -
testcase_02 AC 129 ms
29,656 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 WA -
testcase_15 WA -
testcase_16 RE -
testcase_17 MLE -
testcase_18 RE -
testcase_19 MLE -
testcase_20 AC 699 ms
29,140 KB
testcase_21 AC 133 ms
29,384 KB
testcase_22 AC 131 ms
29,108 KB
testcase_23 AC 130 ms
29,196 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 129 ms
29,252 KB
testcase_27 AC 133 ms
29,124 KB
testcase_28 AC 132 ms
29,280 KB
testcase_29 RE -
testcase_30 RE -
testcase_31 AC 130 ms
29,356 KB
testcase_32 AC 131 ms
29,316 KB
testcase_33 AC 129 ms
29,236 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(search(0,L))
0