結果

問題 No.5 数字のブロック
ユーザー MarioMario
提出日時 2019-07-07 14:11:43
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 404 bytes
コンパイル時間 178 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 71,044 KB
最終ジャッジ日時 2024-04-15 04:16:32
合計ジャッジ時間 3,232 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,752 KB
testcase_01 AC 30 ms
10,624 KB
testcase_02 AC 30 ms
10,752 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 719 ms
71,044 KB
testcase_15 AC 81 ms
17,472 KB
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 AC 31 ms
10,624 KB
testcase_21 AC 31 ms
10,752 KB
testcase_22 AC 31 ms
10,752 KB
testcase_23 AC 32 ms
10,752 KB
testcase_24 AC 188 ms
25,220 KB
testcase_25 RE -
testcase_26 AC 32 ms
10,752 KB
testcase_27 AC 29 ms
10,752 KB
testcase_28 AC 29 ms
10,752 KB
testcase_29 RE -
testcase_30 RE -
testcase_31 AC 32 ms
10,752 KB
testcase_32 AC 30 ms
10,752 KB
testcase_33 AC 29 ms
10,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from functools import lru_cache
import sys
sys.setrecursionlimit(100000)

l = int(input())
n = int(input())
width = list(map(int, input().split()))

@lru_cache(maxsize=None)
def dp(i, w):

    if i == 0:
        return 1 if w >= width[0] else 0
    else:
        if w >= width[i]:
            return max(1 + dp(i-1, w-width[i]), dp(i-1, w))
        else:
            return dp(i-1, w)

print(dp(n-1, l))
0