結果

問題 No.390 最長の数列
ユーザー s_shoheis_shohei
提出日時 2020-06-14 16:08:45
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,717 ms / 5,000 ms
コード長 577 bytes
コンパイル時間 316 ms
コンパイル使用メモリ 87,260 KB
実行使用メモリ 95,144 KB
最終ジャッジ日時 2023-09-09 19:30:52
合計ジャッジ時間 11,419 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 92 ms
71,844 KB
testcase_01 AC 93 ms
71,968 KB
testcase_02 AC 94 ms
71,776 KB
testcase_03 AC 91 ms
72,028 KB
testcase_04 AC 93 ms
71,636 KB
testcase_05 AC 1,717 ms
94,728 KB
testcase_06 AC 1,303 ms
94,820 KB
testcase_07 AC 90 ms
71,472 KB
testcase_08 AC 89 ms
71,868 KB
testcase_09 AC 88 ms
71,824 KB
testcase_10 AC 1,313 ms
94,692 KB
testcase_11 AC 1,311 ms
95,008 KB
testcase_12 AC 1,308 ms
94,700 KB
testcase_13 AC 903 ms
90,748 KB
testcase_14 AC 626 ms
95,144 KB
testcase_15 AC 91 ms
71,844 KB
testcase_16 AC 97 ms
77,100 KB
testcase_17 AC 165 ms
78,304 KB
testcase_18 AC 197 ms
78,468 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
x = list(map(int, input().split()))
def m_div(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

from collections import defaultdict
d = defaultdict(int)
for num in x:
    d[num]=1

x.sort(reverse=True)
for num in x:
    now_len=d[num] # must be 1 or greater
    for div in m_div(num):
        if div==num or (not div in d):
            continue
        d[div] = max(d[div],now_len + 1)

print(max(d.values()))
0