結果

問題 No.390 最長の数列
ユーザー 👑 rin204rin204
提出日時 2022-07-02 20:04:17
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 202 ms / 5,000 ms
コード長 261 bytes
コンパイル時間 286 ms
コンパイル使用メモリ 87,344 KB
実行使用メモリ 109,172 KB
最終ジャッジ日時 2023-08-18 12:04:43
合計ジャッジ時間 3,503 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,232 KB
testcase_01 AC 75 ms
71,376 KB
testcase_02 AC 72 ms
70,916 KB
testcase_03 AC 73 ms
71,292 KB
testcase_04 AC 73 ms
71,284 KB
testcase_05 AC 126 ms
108,844 KB
testcase_06 AC 202 ms
108,280 KB
testcase_07 AC 73 ms
71,120 KB
testcase_08 AC 75 ms
79,036 KB
testcase_09 AC 82 ms
83,380 KB
testcase_10 AC 166 ms
109,004 KB
testcase_11 AC 163 ms
109,164 KB
testcase_12 AC 160 ms
109,172 KB
testcase_13 AC 143 ms
103,208 KB
testcase_14 AC 141 ms
102,120 KB
testcase_15 AC 73 ms
71,568 KB
testcase_16 AC 74 ms
79,016 KB
testcase_17 AC 93 ms
84,384 KB
testcase_18 AC 96 ms
84,660 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
X = set(map(int, input().split()))
ma = max(X)
dp = [0] * (ma + 1)
ans = 1
for x in sorted(X):
    if dp[x] == 0:
        dp[x] = 1
    ans = max(ans, dp[x])
    for j in range(2 * x, ma + 1, x):
        dp[j] = max(dp[j], dp[x] + 1)
print(ans)
0