結果

問題 No.979 Longest Divisor Sequence
ユーザー SalmonizeSalmonize
提出日時 2020-08-17 09:40:20
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,820 ms / 2,000 ms
コード長 609 bytes
コンパイル時間 258 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 94,924 KB
最終ジャッジ日時 2024-04-19 18:41:14
合計ジャッジ時間 5,150 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
10,752 KB
testcase_01 AC 35 ms
10,496 KB
testcase_02 AC 35 ms
10,624 KB
testcase_03 AC 34 ms
10,624 KB
testcase_04 AC 34 ms
10,624 KB
testcase_05 AC 29 ms
10,752 KB
testcase_06 AC 31 ms
10,624 KB
testcase_07 AC 33 ms
10,624 KB
testcase_08 AC 33 ms
10,496 KB
testcase_09 AC 32 ms
10,496 KB
testcase_10 AC 199 ms
40,576 KB
testcase_11 AC 211 ms
41,600 KB
testcase_12 AC 202 ms
40,192 KB
testcase_13 AC 108 ms
16,112 KB
testcase_14 AC 1,820 ms
94,924 KB
testcase_15 AC 767 ms
67,316 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

readline = sys.stdin.readline

ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))

def solve():
    n = ni()
    a = nl()
    s = set(a)
    m = max(a) + 5
    g = [[1] for _ in range(m)]
    for i in range(2, m):
        if i in s:
            for j in range(i*2, m, i):
                g[j].append(i)
    c = [-1]*m
    c[1] = 0
    for x in a:
        if x == 1:
            c[x] = 1
        else:
            c[x] = max([c[y] for y in g[x]]) + 1
    print(max(c))
    return

solve()
0