結果

問題 No.390 最長の数列
ユーザー nanaenanae
提出日時 2017-01-06 16:05:04
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 556 bytes
コンパイル時間 102 ms
コンパイル使用メモリ 10,740 KB
実行使用メモリ 27,568 KB
最終ジャッジ日時 2023-08-22 15:17:03
合計ジャッジ時間 7,367 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
27,568 KB
testcase_01 AC 15 ms
7,840 KB
testcase_02 AC 15 ms
7,836 KB
testcase_03 AC 15 ms
7,940 KB
testcase_04 WA -
testcase_05 TLE -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

# yukicoder No.390 最長の数列

N = int(input())
X = sorted([int(x) for x in input().split()])
check = [0] * N
max_len = 1

for (i, x) in enumerate(X):
    l = 1
    xp = x

    if check[i] == 1: # 昇順にソートされているので既にチェックされた要素から始まる数列は見なくてよい
        continue
    else:
        for (j, y) in enumerate(X[i + 1:]):
            if y % xp == 0:
                check[i + j + 1] = 1
                l += 1
                max_len = max(l, max_len)
                xp = y

print(max_len)
0