結果

問題 No.5 数字のブロック
ユーザー Ryushi-techRyushi-tech
提出日時 2020-06-26 21:32:18
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 324 bytes
コンパイル時間 720 ms
コンパイル使用メモリ 87,156 KB
実行使用メモリ 77,044 KB
最終ジャッジ日時 2023-09-18 03:12:26
合計ジャッジ時間 9,696 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,464 KB
testcase_01 AC 69 ms
71,172 KB
testcase_02 AC 74 ms
71,460 KB
testcase_03 AC 516 ms
76,412 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 283 ms
77,000 KB
testcase_07 AC 375 ms
76,528 KB
testcase_08 AC 224 ms
76,728 KB
testcase_09 AC 144 ms
76,564 KB
testcase_10 AC 360 ms
76,548 KB
testcase_11 AC 155 ms
76,876 KB
testcase_12 AC 512 ms
76,644 KB
testcase_13 AC 364 ms
76,664 KB
testcase_14 AC 87 ms
75,880 KB
testcase_15 WA -
testcase_16 AC 558 ms
76,820 KB
testcase_17 AC 689 ms
76,656 KB
testcase_18 AC 408 ms
76,684 KB
testcase_19 AC 856 ms
76,732 KB
testcase_20 AC 76 ms
75,948 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 70 ms
71,468 KB
testcase_24 AC 80 ms
76,308 KB
testcase_25 AC 121 ms
76,484 KB
testcase_26 AC 75 ms
76,036 KB
testcase_27 AC 76 ms
75,936 KB
testcase_28 AC 75 ms
75,692 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 76 ms
76,036 KB
testcase_32 AC 74 ms
75,932 KB
testcase_33 AC 72 ms
71,488 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, -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]) if l > 1 else dp[1])
#print(dp[:l - 1])
0