結果

問題 No.979 Longest Divisor Sequence
ユーザー rlangevinrlangevin
提出日時 2023-11-10 08:55:04
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,185 ms / 2,000 ms
コード長 390 bytes
コンパイル時間 222 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 226,444 KB
最終ジャッジ日時 2023-11-10 08:55:24
合計ジャッジ時間 15,747 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 847 ms
167,620 KB
testcase_01 AC 784 ms
167,620 KB
testcase_02 AC 827 ms
167,620 KB
testcase_03 AC 837 ms
167,620 KB
testcase_04 AC 748 ms
167,620 KB
testcase_05 AC 823 ms
167,620 KB
testcase_06 AC 776 ms
167,620 KB
testcase_07 AC 737 ms
167,620 KB
testcase_08 AC 785 ms
167,620 KB
testcase_09 AC 758 ms
167,620 KB
testcase_10 AC 751 ms
168,784 KB
testcase_11 AC 824 ms
169,040 KB
testcase_12 AC 859 ms
169,040 KB
testcase_13 AC 815 ms
170,852 KB
testcase_14 AC 1,185 ms
226,444 KB
testcase_15 AC 937 ms
188,724 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import *

N = int(input())
A = list(map(int, input().split()))
M = 3 * 10 **5 + 5
D = [[] for i in range(M)]
for i in range(1, M):
    for j in range(2 * i ,M, i):
        D[j].append(i)

dic = defaultdict(int)
for a in A:
    val = 0
    for d in D[a]:
        val = max(val, dic[d])
    dic[a] = val + 1

ans = 0
for k, v in dic.items():
    ans = max(ans, v)

print(ans)
0