結果

問題 No.390 最長の数列
ユーザー potoooooooopotoooooooo
提出日時 2019-01-18 00:53:02
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 70 ms / 5,000 ms
コード長 448 bytes
コンパイル時間 1,509 ms
コンパイル使用メモリ 166,200 KB
実行使用メモリ 7,020 KB
最終ジャッジ日時 2023-09-14 02:07:43
合計ジャッジ時間 3,086 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
6,980 KB
testcase_01 AC 27 ms
6,948 KB
testcase_02 AC 29 ms
6,960 KB
testcase_03 AC 28 ms
6,992 KB
testcase_04 AC 28 ms
6,948 KB
testcase_05 AC 56 ms
6,932 KB
testcase_06 AC 67 ms
7,000 KB
testcase_07 AC 28 ms
6,968 KB
testcase_08 AC 28 ms
7,020 KB
testcase_09 AC 29 ms
6,992 KB
testcase_10 AC 70 ms
6,972 KB
testcase_11 AC 69 ms
6,892 KB
testcase_12 AC 68 ms
6,884 KB
testcase_13 AC 49 ms
6,964 KB
testcase_14 AC 53 ms
6,892 KB
testcase_15 AC 28 ms
6,896 KB
testcase_16 AC 29 ms
6,852 KB
testcase_17 AC 31 ms
6,964 KB
testcase_18 AC 32 ms
6,936 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
    int n; cin >> n;
    vector<int> v(1000010, 0);
    for (int i = 0; i < n; i++) {
        int k; cin >> k;
        v[k]++;
    }
    int ans = 1;
    for (int i = 1; i < 1000010; i++) {
        for (int j = 2; i * j < 1000010; j++) {
            if (v[i*j] > 0) v[i*j] = max(v[i*j], v[i]+1);
            ans = max(ans, v[i*j]);
        }
    }
    cout << ans << endl;
    return 0;
}
0