結果

問題 No.2218 Multiple LIS
ユーザー mkawa2mkawa2
提出日時 2023-02-17 22:26:25
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 686 ms / 3,000 ms
コード長 1,136 bytes
コンパイル時間 486 ms
コンパイル使用メモリ 87,328 KB
実行使用メモリ 92,608 KB
最終ジャッジ日時 2023-09-26 19:41:59
合計ジャッジ時間 13,099 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
72,612 KB
testcase_01 AC 77 ms
72,496 KB
testcase_02 AC 74 ms
72,608 KB
testcase_03 AC 75 ms
72,284 KB
testcase_04 AC 75 ms
72,512 KB
testcase_05 AC 76 ms
72,568 KB
testcase_06 AC 75 ms
72,292 KB
testcase_07 AC 75 ms
72,668 KB
testcase_08 AC 76 ms
72,384 KB
testcase_09 AC 75 ms
72,576 KB
testcase_10 AC 77 ms
72,460 KB
testcase_11 AC 79 ms
77,104 KB
testcase_12 AC 80 ms
77,140 KB
testcase_13 AC 84 ms
77,468 KB
testcase_14 AC 84 ms
77,392 KB
testcase_15 AC 85 ms
77,356 KB
testcase_16 AC 80 ms
77,108 KB
testcase_17 AC 84 ms
77,516 KB
testcase_18 AC 78 ms
77,112 KB
testcase_19 AC 81 ms
76,920 KB
testcase_20 AC 84 ms
77,756 KB
testcase_21 AC 125 ms
77,888 KB
testcase_22 AC 309 ms
82,076 KB
testcase_23 AC 457 ms
85,316 KB
testcase_24 AC 167 ms
77,636 KB
testcase_25 AC 497 ms
86,780 KB
testcase_26 AC 671 ms
91,412 KB
testcase_27 AC 674 ms
91,444 KB
testcase_28 AC 686 ms
91,416 KB
testcase_29 AC 677 ms
91,136 KB
testcase_30 AC 676 ms
91,588 KB
testcase_31 AC 454 ms
90,948 KB
testcase_32 AC 448 ms
91,072 KB
testcase_33 AC 450 ms
91,324 KB
testcase_34 AC 450 ms
91,060 KB
testcase_35 AC 448 ms
91,024 KB
testcase_36 AC 95 ms
90,236 KB
testcase_37 AC 569 ms
92,608 KB
testcase_38 AC 73 ms
72,508 KB
testcase_39 AC 73 ms
72,568 KB
testcase_40 AC 646 ms
90,912 KB
testcase_41 AC 645 ms
91,004 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

# sys.setrecursionlimit(200005)
int1 = lambda x: int(x)-1
pDB = lambda *x: print(*x, end="\n", file=sys.stderr)
p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr)
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()

# dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
inf = (1 << 63)-1
# inf = (1 << 31)-1
# md = 10**9+7
md = 998244353

mx = 10**5
n = II()
aa = LI()
border = round(mx**0.5)
# border=3

dp = [0]*100005
seen=set()
ans = 1
for a in aa:
    for b in range(1, min(a+1, border))[::-1]:
        if a%b: continue
        dp[a] = max(dp[a], dp[b]+1)
    # pDB(a,dp[a])
    ans = max(ans, dp[a])
    if a >= border:
        dp[a]+=1
        for b in range(a, 100001, a):
            dp[b] = max(dp[b], dp[a])
    # pDB(dp[:40])

print(ans)
0