結果

問題 No.390 最長の数列
ユーザー 🍮かんプリン🍮かんプリン
提出日時 2020-06-02 18:41:11
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 75 ms / 5,000 ms
コード長 758 bytes
コンパイル時間 1,210 ms
コンパイル使用メモリ 149,316 KB
実行使用メモリ 7,800 KB
最終ジャッジ日時 2023-08-15 22:00:20
合計ジャッジ時間 2,904 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
6,948 KB
testcase_01 AC 6 ms
7,004 KB
testcase_02 AC 6 ms
7,004 KB
testcase_03 AC 6 ms
7,084 KB
testcase_04 AC 6 ms
6,876 KB
testcase_05 AC 42 ms
7,800 KB
testcase_06 AC 75 ms
7,724 KB
testcase_07 AC 5 ms
6,884 KB
testcase_08 AC 5 ms
7,244 KB
testcase_09 AC 5 ms
6,948 KB
testcase_10 AC 47 ms
7,736 KB
testcase_11 AC 47 ms
7,736 KB
testcase_12 AC 46 ms
7,668 KB
testcase_13 AC 34 ms
7,488 KB
testcase_14 AC 66 ms
7,744 KB
testcase_15 AC 4 ms
7,016 KB
testcase_16 AC 5 ms
6,924 KB
testcase_17 AC 7 ms
6,976 KB
testcase_18 AC 8 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/**
 *   @FileName	a.cpp
 *   @Author	kanpurin
 *   @Created	2020.06.02 18:41:05
**/

#include "bits/stdc++.h" 
using namespace std; 
typedef long long ll;

int main() {
    int n;cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    vector<int> b(1000000,-1);
    for (int i = 0; i < n; i++) {
        b[a[i]-1] = i;
    }
    vector<int> c(n,1);
    int ans = 1;
    for (int i = 0; i < 1000000; i++) {
        if (b[i] == -1) continue;
        for (int j = 2 * i + 2; j <= 1000000; j += i + 1) {
            if (b[j-1] == -1) continue;
            c[b[j-1]] = max(c[b[j-1]],c[b[i]] + 1);
            ans = max(ans,c[b[j-1]]);
        }
    }
    cout << ans << endl;
    return 0;
}
0