結果

問題 No.390 最長の数列
ユーザー rpy3cpprpy3cpp
提出日時 2016-07-09 08:24:07
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 976 ms / 5,000 ms
コード長 464 bytes
コンパイル時間 103 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 24,296 KB
最終ジャッジ日時 2024-04-10 08:56:07
合計ジャッジ時間 4,243 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,880 KB
testcase_01 AC 30 ms
10,752 KB
testcase_02 AC 30 ms
10,880 KB
testcase_03 AC 31 ms
10,752 KB
testcase_04 AC 29 ms
10,752 KB
testcase_05 AC 164 ms
24,184 KB
testcase_06 AC 976 ms
24,260 KB
testcase_07 AC 30 ms
10,752 KB
testcase_08 AC 105 ms
18,392 KB
testcase_09 AC 151 ms
18,376 KB
testcase_10 AC 272 ms
24,192 KB
testcase_11 AC 284 ms
24,264 KB
testcase_12 AC 267 ms
24,296 KB
testcase_13 AC 357 ms
23,784 KB
testcase_14 AC 177 ms
20,660 KB
testcase_15 AC 31 ms
10,880 KB
testcase_16 AC 105 ms
18,404 KB
testcase_17 AC 112 ms
18,944 KB
testcase_18 AC 114 ms
19,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def read_data():
    N = int(input())
    Xs = list(map(int, input().split()))
    return N, Xs
    
def solve(N, Xs):
    maxX = max(Xs)
    dp = [0] * (maxX + 1)
    for x in Xs:
        dp[x] = 1
    for i in range(1, maxX + 1):
        di = dp[i]
        if di == 0:
            continue
        for j in range(i * 2, maxX + 1, i):
            if dp[j] and di >= dp[j]:
                dp[j] = di + 1
    return max(dp)

N, Xs = read_data()
print(solve(N, Xs))
0