結果

問題 No.390 最長の数列
ユーザー hiyokko2hiyokko2
提出日時 2016-07-30 14:09:20
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 2,953 ms / 5,000 ms
コード長 285 bytes
コンパイル時間 92 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 24,540 KB
最終ジャッジ日時 2024-04-10 10:04:56
合計ジャッジ時間 7,119 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
10,752 KB
testcase_01 AC 30 ms
10,752 KB
testcase_02 AC 29 ms
10,752 KB
testcase_03 AC 29 ms
10,752 KB
testcase_04 AC 30 ms
10,752 KB
testcase_05 AC 170 ms
24,516 KB
testcase_06 AC 2,953 ms
24,236 KB
testcase_07 AC 29 ms
10,752 KB
testcase_08 AC 59 ms
18,412 KB
testcase_09 AC 174 ms
18,348 KB
testcase_10 AC 397 ms
24,492 KB
testcase_11 AC 428 ms
24,540 KB
testcase_12 AC 391 ms
24,388 KB
testcase_13 AC 490 ms
23,392 KB
testcase_14 AC 706 ms
20,732 KB
testcase_15 AC 30 ms
10,752 KB
testcase_16 AC 59 ms
18,588 KB
testcase_17 AC 67 ms
18,836 KB
testcase_18 AC 74 ms
19,252 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
x = sorted(map(int, input().split()))

maxx = x[-1]
dp = [0] * (maxx + 1)

for i in x:
    dp[i] = 1

for i in x:
    for j in range(i * 2, maxx + 1, i):
        if dp[j] == 0:
            continue
        else:
            dp[j] = max(dp[j], dp[i] + 1)
print(max(dp))
0