結果

問題 No.385 カップ麺生活
ユーザー hanorverhanorver
提出日時 2016-07-02 00:15:39
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 623 bytes
コンパイル時間 184 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 11,136 KB
最終ジャッジ日時 2024-04-20 06:25:54
合計ジャッジ時間 2,996 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
11,008 KB
testcase_01 WA -
testcase_02 AC 27 ms
11,136 KB
testcase_03 AC 27 ms
11,008 KB
testcase_04 AC 31 ms
10,880 KB
testcase_05 AC 27 ms
11,008 KB
testcase_06 AC 47 ms
10,880 KB
testcase_07 AC 38 ms
10,880 KB
testcase_08 AC 32 ms
10,880 KB
testcase_09 WA -
testcase_10 AC 172 ms
11,136 KB
testcase_11 AC 25 ms
11,008 KB
testcase_12 AC 37 ms
11,008 KB
testcase_13 AC 61 ms
11,136 KB
testcase_14 AC 62 ms
11,136 KB
testcase_15 AC 52 ms
10,880 KB
testcase_16 AC 29 ms
11,136 KB
testcase_17 AC 89 ms
11,008 KB
testcase_18 WA -
testcase_19 AC 36 ms
11,008 KB
testcase_20 AC 58 ms
11,008 KB
testcase_21 AC 63 ms
11,008 KB
testcase_22 AC 62 ms
11,136 KB
testcase_23 AC 61 ms
11,008 KB
testcase_24 AC 60 ms
11,008 KB
testcase_25 AC 26 ms
11,136 KB
testcase_26 AC 34 ms
11,008 KB
testcase_27 AC 42 ms
11,008 KB
testcase_28 AC 42 ms
11,008 KB
testcase_29 AC 37 ms
11,008 KB
testcase_30 AC 58 ms
11,136 KB
testcase_31 AC 27 ms
10,880 KB
testcase_32 AC 29 ms
11,008 KB
testcase_33 AC 78 ms
10,880 KB
testcase_34 AC 32 ms
11,008 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import math

def is_prime(n):
    for i in range(2, int(math.sqrt(n)) + 1):
        if n % i == 0:
            return False
    return True

def primes(m):
    for i in range(2, m + 1):
        if is_prime(i):
            yield i


m = int(input())
n = input()
values = list(map(int, input().split()))
dp = [0] * 10001
ans = 0

for i, value in enumerate(values):
    dp[value] += 1

for i, value in enumerate(values):
    for j in range(m + 1):
        if dp[j] > 0 and j + value <= m:
            dp[j + value] = max(dp[j] + 1, dp[j + value])

for prime in primes(m):
    ans += dp[m -  prime]

ans += max(dp)

print(ans)
0