結果

問題 No.2218 Multiple LIS
ユーザー jianglyjiangly
提出日時 2023-02-17 21:27:15
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 94 ms / 3,000 ms
コード長 793 bytes
コンパイル時間 2,109 ms
コンパイル使用メモリ 202,528 KB
実行使用メモリ 14,400 KB
最終ジャッジ日時 2023-09-26 18:33:49
合計ジャッジ時間 5,330 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 70 ms
13,908 KB
testcase_22 AC 78 ms
13,820 KB
testcase_23 AC 84 ms
14,168 KB
testcase_24 AC 73 ms
14,064 KB
testcase_25 AC 84 ms
13,992 KB
testcase_26 AC 86 ms
14,292 KB
testcase_27 AC 90 ms
14,200 KB
testcase_28 AC 94 ms
14,200 KB
testcase_29 AC 93 ms
14,128 KB
testcase_30 AC 94 ms
14,144 KB
testcase_31 AC 48 ms
10,368 KB
testcase_32 AC 44 ms
10,472 KB
testcase_33 AC 43 ms
10,488 KB
testcase_34 AC 44 ms
10,392 KB
testcase_35 AC 43 ms
10,420 KB
testcase_36 AC 8 ms
4,376 KB
testcase_37 AC 81 ms
14,400 KB
testcase_38 AC 2 ms
4,384 KB
testcase_39 AC 2 ms
4,380 KB
testcase_40 AC 42 ms
10,428 KB
testcase_41 AC 44 ms
10,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using i64 = long long;

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    
    int n;
    std::cin >> n;
    
    std::vector<int> a(n);
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
    }
    
    int m = *std::max_element(a.begin(), a.end());
    
    std::vector<std::vector<int>> div(m + 1);
    for (int i = 1; i <= m; i++) {
        for (int j = i; j <= m; j += i) {
            div[j].push_back(i);
        }
    }
    
    std::vector<int> f(m + 1);
    int ans = 0;
    for (int i = 0; i < n; i++) {
        int v = 0;
        for (auto x : div[a[i]]) {
            v = std::max(v, f[x] + 1);
        }
        f[a[i]] = v;
        ans = std::max(ans, v);
    }
    std::cout << ans << "\n";
    
    return 0;
}
0