結果

問題 No.385 カップ麺生活
ユーザー ebicochinealebicochineal
提出日時 2016-07-02 19:35:29
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 857 bytes
コンパイル時間 202 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 218,592 KB
最終ジャッジ日時 2024-04-20 06:10:33
合計ジャッジ時間 7,739 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
57,984 KB
testcase_01 AC 47 ms
59,008 KB
testcase_02 AC 38 ms
52,608 KB
testcase_03 AC 45 ms
59,264 KB
testcase_04 AC 111 ms
76,800 KB
testcase_05 AC 44 ms
58,880 KB
testcase_06 AC 66 ms
72,576 KB
testcase_07 AC 95 ms
76,672 KB
testcase_08 AC 72 ms
76,104 KB
testcase_09 AC 38 ms
51,968 KB
testcase_10 AC 120 ms
76,288 KB
testcase_11 AC 38 ms
52,352 KB
testcase_12 AC 89 ms
76,744 KB
testcase_13 AC 256 ms
91,096 KB
testcase_14 AC 875 ms
111,240 KB
testcase_15 AC 109 ms
81,152 KB
testcase_16 AC 48 ms
60,928 KB
testcase_17 AC 562 ms
108,400 KB
testcase_18 AC 71 ms
76,288 KB
testcase_19 AC 79 ms
76,172 KB
testcase_20 AC 151 ms
93,052 KB
testcase_21 AC 199 ms
89,600 KB
testcase_22 AC 309 ms
79,104 KB
testcase_23 AC 151 ms
84,436 KB
testcase_24 TLE -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

def prime_number_list(n): 
    l = [2, 3]
    if n < 5 : return l 
    for i in range(5, n+1, 2):
        if all([0 if i % x == 0 else 1 for x in l]):
            l += [i]
    return l

def main():
    M = int(input())
    N = int(input())
    C = sorted(list(map(int, input().split())))
    p = set(prime_number_list(M))
    ans = M // min(C)
    q = [0]
    cnt = 0
    l = [0] * (M + sum(C))
    C_ = [C[0]]
    for i in range(1, len(C)):
        if all([0 if C[i] % x == 0 else 1 for x in C[:i]]):
            C_ += [C[i]]
    while q:
        cnt += 1
        s = set(filter(lambda x : x <= M, q))
        q = []
        for i in s:
            for j in C_:
                a = i + j
                q += [a]
                l[M - a] = cnt
    for i in range(M):
        if i+1 in p : ans += l[i+1]
    print(ans)

if __name__ == '__main__':
    main()
0