結果

問題 No.390 最長の数列
ユーザー ntudantuda
提出日時 2024-01-08 20:28:31
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 160 ms / 5,000 ms
コード長 290 bytes
コンパイル時間 251 ms
コンパイル使用メモリ 81,572 KB
実行使用メモリ 97,996 KB
最終ジャッジ日時 2024-01-08 20:28:34
合計ジャッジ時間 2,683 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
53,332 KB
testcase_01 AC 37 ms
53,332 KB
testcase_02 AC 37 ms
53,332 KB
testcase_03 AC 35 ms
53,332 KB
testcase_04 AC 36 ms
53,332 KB
testcase_05 AC 83 ms
90,832 KB
testcase_06 AC 160 ms
97,276 KB
testcase_07 AC 36 ms
53,332 KB
testcase_08 AC 39 ms
61,192 KB
testcase_09 AC 46 ms
67,332 KB
testcase_10 AC 114 ms
97,800 KB
testcase_11 AC 111 ms
97,800 KB
testcase_12 AC 127 ms
97,996 KB
testcase_13 AC 95 ms
90,920 KB
testcase_14 AC 97 ms
90,324 KB
testcase_15 AC 35 ms
53,460 KB
testcase_16 AC 38 ms
61,140 KB
testcase_17 AC 56 ms
74,208 KB
testcase_18 AC 57 ms
74,200 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
A = list(map(int, input().split()))
A.sort()
maxx = A[-1]
dp = [0] * (maxx + 1)
for i in range(N):
    a = A[i]
    dp[a] = max(dp[a], 1)
    for j in range(a * 2, maxx + 1, a):
        dp[j] = max(dp[j], dp[a] + 1)
ans = 0
for a in A:
    ans = max(ans, dp[a])
print(ans)
0