結果

問題 No.2218 Multiple LIS
ユーザー FromBooskaFromBooska
提出日時 2023-04-16 21:03:12
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 685 ms / 3,000 ms
コード長 690 bytes
コンパイル時間 651 ms
コンパイル使用メモリ 82,472 KB
実行使用メモリ 94,848 KB
最終ジャッジ日時 2024-04-20 08:03:32
合計ジャッジ時間 9,355 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,200 KB
testcase_01 AC 37 ms
52,280 KB
testcase_02 AC 38 ms
52,468 KB
testcase_03 AC 38 ms
53,732 KB
testcase_04 AC 39 ms
53,096 KB
testcase_05 AC 38 ms
52,820 KB
testcase_06 AC 38 ms
53,356 KB
testcase_07 AC 37 ms
52,124 KB
testcase_08 AC 38 ms
52,140 KB
testcase_09 AC 38 ms
52,948 KB
testcase_10 AC 38 ms
54,188 KB
testcase_11 AC 39 ms
53,116 KB
testcase_12 AC 45 ms
60,012 KB
testcase_13 AC 51 ms
64,396 KB
testcase_14 AC 51 ms
62,920 KB
testcase_15 AC 51 ms
64,128 KB
testcase_16 AC 42 ms
58,716 KB
testcase_17 AC 52 ms
63,424 KB
testcase_18 AC 38 ms
52,812 KB
testcase_19 AC 41 ms
58,168 KB
testcase_20 AC 51 ms
64,588 KB
testcase_21 AC 76 ms
73,092 KB
testcase_22 AC 198 ms
80,512 KB
testcase_23 AC 301 ms
84,172 KB
testcase_24 AC 108 ms
76,916 KB
testcase_25 AC 338 ms
85,248 KB
testcase_26 AC 446 ms
90,444 KB
testcase_27 AC 447 ms
90,112 KB
testcase_28 AC 449 ms
90,660 KB
testcase_29 AC 449 ms
90,860 KB
testcase_30 AC 451 ms
90,388 KB
testcase_31 AC 198 ms
89,472 KB
testcase_32 AC 228 ms
89,420 KB
testcase_33 AC 199 ms
89,344 KB
testcase_34 AC 201 ms
89,612 KB
testcase_35 AC 226 ms
89,472 KB
testcase_36 AC 84 ms
88,344 KB
testcase_37 AC 685 ms
94,848 KB
testcase_38 AC 39 ms
53,200 KB
testcase_39 AC 39 ms
53,380 KB
testcase_40 AC 668 ms
90,020 KB
testcase_41 AC 672 ms
89,984 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# 2次元dpで間に合うのか? 10**5の2乗になるのでは?

N = int(input())
A = list(map(int, input().split()))
maxA = max(A)

def divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

dp = [0]*(maxA+1)
for a in A:
    divs = divisors(a)[::-1]
    # 自身を参照するときにオーバーカウントしないように自身を最初に参照
    for d in divs:
        dp[a] = max(dp[a], dp[d]+1)
    #print('a', a, dp)
ans = max(dp)
print(ans)

0