結果

問題 No.390 最長の数列
ユーザー nebukuro09nebukuro09
提出日時 2016-10-15 10:00:19
言語 Python2
(2.7.18)
結果
AC  
実行時間 4,605 ms / 5,000 ms
コード長 291 bytes
コンパイル時間 88 ms
コンパイル使用メモリ 6,516 KB
実行使用メモリ 40,948 KB
最終ジャッジ日時 2023-08-14 13:43:38
合計ジャッジ時間 13,136 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
6,188 KB
testcase_01 AC 11 ms
6,004 KB
testcase_02 AC 12 ms
6,056 KB
testcase_03 AC 11 ms
6,188 KB
testcase_04 AC 11 ms
6,196 KB
testcase_05 AC 388 ms
40,824 KB
testcase_06 AC 4,605 ms
40,804 KB
testcase_07 AC 11 ms
6,028 KB
testcase_08 AC 263 ms
37,684 KB
testcase_09 AC 564 ms
37,544 KB
testcase_10 AC 915 ms
40,860 KB
testcase_11 AC 981 ms
40,860 KB
testcase_12 AC 932 ms
40,948 KB
testcase_13 AC 1,415 ms
40,348 KB
testcase_14 AC 797 ms
14,728 KB
testcase_15 AC 16 ms
6,672 KB
testcase_16 AC 274 ms
37,516 KB
testcase_17 AC 297 ms
37,804 KB
testcase_18 AC 313 ms
37,892 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

m = max(x)
dp = [float('-inf') for _ in xrange(m+1)]
for a in x:
    dp[a] = 1

for a in x:
    b = a*2
    c = dp[a]
    while b <= m:
        if dp[b] != float('-inf'):
            dp[b] = max(c+1, dp[b])
        b += a

print max(dp)
0