結果

問題 No.385 カップ麺生活
ユーザー qibqib
提出日時 2023-02-26 15:22:48
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 115 ms / 2,000 ms
コード長 585 bytes
コンパイル時間 1,003 ms
コンパイル使用メモリ 87,164 KB
実行使用メモリ 76,804 KB
最終ジャッジ日時 2023-10-12 06:46:07
合計ジャッジ時間 6,447 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
71,552 KB
testcase_01 AC 77 ms
71,348 KB
testcase_02 AC 76 ms
71,240 KB
testcase_03 AC 115 ms
76,032 KB
testcase_04 AC 100 ms
76,232 KB
testcase_05 AC 85 ms
76,292 KB
testcase_06 AC 96 ms
76,756 KB
testcase_07 AC 99 ms
76,612 KB
testcase_08 AC 94 ms
76,480 KB
testcase_09 AC 76 ms
71,484 KB
testcase_10 AC 96 ms
76,592 KB
testcase_11 AC 76 ms
71,212 KB
testcase_12 AC 93 ms
76,492 KB
testcase_13 AC 98 ms
76,572 KB
testcase_14 AC 100 ms
76,756 KB
testcase_15 AC 99 ms
76,732 KB
testcase_16 AC 88 ms
76,440 KB
testcase_17 AC 97 ms
76,572 KB
testcase_18 AC 92 ms
76,136 KB
testcase_19 AC 94 ms
76,432 KB
testcase_20 AC 99 ms
76,324 KB
testcase_21 AC 98 ms
76,728 KB
testcase_22 AC 96 ms
76,624 KB
testcase_23 AC 98 ms
76,748 KB
testcase_24 AC 96 ms
76,620 KB
testcase_25 AC 81 ms
75,788 KB
testcase_26 AC 93 ms
76,724 KB
testcase_27 AC 95 ms
76,804 KB
testcase_28 AC 95 ms
76,764 KB
testcase_29 AC 94 ms
76,540 KB
testcase_30 AC 96 ms
76,588 KB
testcase_31 AC 85 ms
76,612 KB
testcase_32 AC 90 ms
76,176 KB
testcase_33 AC 96 ms
76,712 KB
testcase_34 AC 96 ms
76,324 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

INF = 1 << 60

m = int(input())
n = int(input())
c = list(map(int, input().split()))

dp = [- INF for _ in range(m + 1)]
dp[m] = 0
for cur in range(m, 0, -1):
  if dp[m] == - INF:
    continue
  for i in range(n):
    nxt = cur - c[i]
    if nxt >= 0:
      dp[nxt] = max(dp[nxt], dp[cur] + 1)

div = [None for _ in range(m + 1)]
div[0] = 1
div[1] = 1
for x in range(m + 1):
  if not div[x] is None:
    continue
  for y in range(x, m + 1, x):
    if div[y] is None:
      div[y] = x

ans = max(dp)
for x in range(2, m + 1):
  if dp[x] > 0 and div[x] == x:
    ans += dp[x]

print(ans)
0