結果

問題 No.2218 Multiple LIS
ユーザー milanis48663220milanis48663220
提出日時 2023-02-17 22:10:19
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 82 ms / 3,000 ms
コード長 1,832 bytes
コンパイル時間 1,186 ms
コンパイル使用メモリ 119,580 KB
実行使用メモリ 14,316 KB
最終ジャッジ日時 2023-09-26 19:26:04
合計ジャッジ時間 5,693 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 56 ms
13,804 KB
testcase_01 AC 54 ms
13,652 KB
testcase_02 AC 59 ms
13,664 KB
testcase_03 AC 56 ms
13,752 KB
testcase_04 AC 57 ms
13,752 KB
testcase_05 AC 54 ms
13,816 KB
testcase_06 AC 55 ms
13,796 KB
testcase_07 AC 56 ms
13,660 KB
testcase_08 AC 56 ms
13,668 KB
testcase_09 AC 56 ms
13,728 KB
testcase_10 AC 57 ms
13,724 KB
testcase_11 AC 57 ms
13,864 KB
testcase_12 AC 57 ms
13,756 KB
testcase_13 AC 56 ms
13,820 KB
testcase_14 AC 57 ms
13,876 KB
testcase_15 AC 57 ms
13,992 KB
testcase_16 AC 58 ms
13,952 KB
testcase_17 AC 62 ms
13,672 KB
testcase_18 AC 58 ms
13,736 KB
testcase_19 AC 57 ms
13,664 KB
testcase_20 AC 61 ms
13,676 KB
testcase_21 AC 61 ms
14,072 KB
testcase_22 AC 66 ms
14,136 KB
testcase_23 AC 72 ms
14,120 KB
testcase_24 AC 63 ms
14,096 KB
testcase_25 AC 72 ms
14,192 KB
testcase_26 AC 80 ms
14,260 KB
testcase_27 AC 80 ms
14,316 KB
testcase_28 AC 80 ms
14,272 KB
testcase_29 AC 82 ms
14,256 KB
testcase_30 AC 78 ms
14,304 KB
testcase_31 AC 70 ms
13,972 KB
testcase_32 AC 76 ms
13,920 KB
testcase_33 AC 72 ms
13,928 KB
testcase_34 AC 72 ms
13,992 KB
testcase_35 AC 74 ms
13,880 KB
testcase_36 AC 71 ms
13,896 KB
testcase_37 AC 80 ms
13,896 KB
testcase_38 AC 59 ms
13,732 KB
testcase_39 AC 60 ms
13,944 KB
testcase_40 AC 70 ms
14,040 KB
testcase_41 AC 75 ms
13,996 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cmath>
#include <numeric>
#include <functional>
#include <cassert>

#define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl;
#define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using namespace std;
typedef long long ll;

template<typename T>
vector<vector<T>> vec2d(int n, int m, T v){
    return vector<vector<T>>(n, vector<T>(m, v));
}

template<typename T>
vector<vector<vector<T>>> vec3d(int n, int m, int k, T v){
    return vector<vector<vector<T>>>(n, vector<vector<T>>(m, vector<T>(k, v)));
}

template<typename T>
void print_vector(vector<T> v, char delimiter=' '){
    if(v.empty()) {
        cout << endl;
        return;
    }
    for(int i = 0; i+1 < v.size(); i++) cout << v[i] << delimiter;
    cout << v.back() << endl;
}

const int N = 100000;
vector<int> facs[N+1];

void init(){
    for(int x = 1; x <= N; x++){
        for(int i = 1; i*x <= N; i++){
            facs[i*x].push_back(x);
        }
    }
}

int dp[N+1];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    init();
    int n; cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = 0; i < n; i++){
        int mx = 0;
        for(int x: facs[a[i]]){
            chmax(mx, dp[x]);
        }
        chmax(dp[a[i]], mx+1);
    }
    int ans = 0;
    for(int x = 1; x <= N; x++) chmax(ans, dp[x]);
    cout << ans << endl;
}
0