結果

問題 No.2218 Multiple LIS
ユーザー hourenhouren
提出日時 2023-02-17 22:08:57
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 134 ms / 3,000 ms
コード長 1,096 bytes
コンパイル時間 1,923 ms
コンパイル使用メモリ 170,396 KB
実行使用メモリ 18,044 KB
最終ジャッジ日時 2023-09-26 19:25:00
合計ジャッジ時間 6,890 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
16,036 KB
testcase_01 AC 68 ms
15,936 KB
testcase_02 AC 67 ms
15,980 KB
testcase_03 AC 72 ms
15,916 KB
testcase_04 AC 70 ms
16,036 KB
testcase_05 AC 70 ms
15,876 KB
testcase_06 AC 73 ms
15,928 KB
testcase_07 AC 71 ms
15,884 KB
testcase_08 AC 80 ms
15,876 KB
testcase_09 AC 72 ms
16,016 KB
testcase_10 AC 75 ms
15,968 KB
testcase_11 AC 71 ms
16,004 KB
testcase_12 AC 74 ms
15,984 KB
testcase_13 AC 79 ms
16,044 KB
testcase_14 AC 72 ms
16,024 KB
testcase_15 AC 70 ms
15,892 KB
testcase_16 AC 73 ms
15,756 KB
testcase_17 AC 70 ms
15,924 KB
testcase_18 AC 71 ms
15,852 KB
testcase_19 AC 71 ms
15,836 KB
testcase_20 AC 71 ms
15,976 KB
testcase_21 AC 73 ms
16,064 KB
testcase_22 AC 90 ms
16,496 KB
testcase_23 AC 101 ms
16,944 KB
testcase_24 AC 82 ms
15,956 KB
testcase_25 AC 109 ms
17,204 KB
testcase_26 AC 122 ms
17,868 KB
testcase_27 AC 134 ms
17,752 KB
testcase_28 AC 126 ms
17,848 KB
testcase_29 AC 124 ms
18,044 KB
testcase_30 AC 124 ms
17,856 KB
testcase_31 AC 85 ms
17,292 KB
testcase_32 AC 83 ms
17,292 KB
testcase_33 AC 87 ms
17,020 KB
testcase_34 AC 81 ms
16,956 KB
testcase_35 AC 86 ms
17,080 KB
testcase_36 AC 77 ms
17,260 KB
testcase_37 AC 80 ms
17,136 KB
testcase_38 AC 73 ms
15,920 KB
testcase_39 AC 89 ms
15,876 KB
testcase_40 AC 93 ms
17,260 KB
testcase_41 AC 94 ms
17,280 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define fix(x) fixed << setprecision(x)
#define asc(x) x, vector<x>, greater<x>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
template<class T>bool chmin(T&a, const T&b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool chmax(T&a, const T&b){if(a<b){a=b;return 1;}return 0;}
constexpr ll INFLL = (1LL << 62), MOD = 998244353;
constexpr int INF = (1 << 30);

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<vector<int>> v(100100), div(100100);
    for(int i=1;i<=100000;i++){
        for(int j=i;j<=100000;j+=i) div[j].push_back(i);
    }
    vector<int> a(n);
    rep(i,n){
        cin >> a[i];
        v[a[i]].push_back(i);
    }
    vector<int> dp(n,1);
    for(int i=n-1;i>=0;i--){
        v[a[i]].pop_back();
        for(int x:div[a[i]]){
            if(v[x].size()){
                chmax(dp[v[x].back()], dp[i]+1);
            }
        }
    }
    cout << *max_element(all(dp)) << '\n';
    return 0;
}
0