結果

問題 No.5 数字のブロック
ユーザー Ryushi-techRyushi-tech
提出日時 2020-06-26 21:40:33
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 855 ms / 5,000 ms
コード長 279 bytes
コンパイル時間 745 ms
コンパイル使用メモリ 86,996 KB
実行使用メモリ 76,880 KB
最終ジャッジ日時 2023-09-18 03:37:27
合計ジャッジ時間 10,102 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,332 KB
testcase_01 AC 72 ms
71,316 KB
testcase_02 AC 69 ms
71,400 KB
testcase_03 AC 520 ms
76,688 KB
testcase_04 AC 90 ms
76,564 KB
testcase_05 AC 530 ms
76,620 KB
testcase_06 AC 276 ms
76,616 KB
testcase_07 AC 375 ms
76,308 KB
testcase_08 AC 225 ms
76,552 KB
testcase_09 AC 147 ms
76,728 KB
testcase_10 AC 363 ms
76,592 KB
testcase_11 AC 158 ms
76,680 KB
testcase_12 AC 513 ms
76,612 KB
testcase_13 AC 365 ms
76,612 KB
testcase_14 AC 90 ms
75,788 KB
testcase_15 AC 83 ms
76,300 KB
testcase_16 AC 549 ms
76,736 KB
testcase_17 AC 691 ms
76,880 KB
testcase_18 AC 406 ms
76,444 KB
testcase_19 AC 855 ms
76,768 KB
testcase_20 AC 76 ms
76,080 KB
testcase_21 AC 71 ms
71,104 KB
testcase_22 AC 71 ms
71,280 KB
testcase_23 AC 71 ms
71,308 KB
testcase_24 AC 83 ms
76,524 KB
testcase_25 AC 124 ms
76,468 KB
testcase_26 AC 75 ms
75,864 KB
testcase_27 AC 76 ms
75,876 KB
testcase_28 AC 75 ms
75,828 KB
testcase_29 AC 93 ms
76,328 KB
testcase_30 AC 108 ms
76,620 KB
testcase_31 AC 77 ms
75,560 KB
testcase_32 AC 76 ms
75,848 KB
testcase_33 AC 71 ms
71,320 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

dp = [-1] * (l+1)
dp[0] = 0

for w in W:
    for i in range(l, -1, -1):
      if i + w > l:
        continue
      elif dp[i] >= 0:
        dp[i + w] = max(dp[i] + 1, dp[i + w])

print(max(dp[:l+1]))
0