結果

問題 No.2218 Multiple LIS
ユーザー umimel
提出日時 2023-02-17 21:48:15
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 335 ms / 3,000 ms
コード長 997 bytes
コンパイル時間 1,497 ms
コンパイル使用メモリ 168,528 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-19 13:00:18
合計ジャッジ時間 5,614 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 39
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
#define drep(i, cc, n) for (ll i = (cc); i <= (n); ++i)
#define rep(i, n) drep(i, 0, n - 1)
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define fi first
#define se second

const ll MOD = 1000000007;
const ll MOD2 = 998244353;
const ll INF = 1LL << 60;
const ll MAX_N = 2e5;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    ll n; cin >> n;
    vector<ll> a(n); rep(i, n) cin >> a[i];

    ll MAX = 1e5;
    vector<ll> dp(MAX+1, 0);
    for(ll i=0; i<n; i++){
        for(ll j=1; j*j<=a[i]; j++){
            if(a[i]%j!=0) continue;
            if(a[i]/j==j){
                dp[a[i]] = max(dp[a[i]], dp[j]+1);
            }else{
                dp[a[i]] = max(dp[a[i]], dp[a[i]/j]+1);
                dp[a[i]] = max(dp[a[i]], dp[j]+1);
            }
        }
    }

    ll ans = 0;
    for(ll i=0; i<=MAX; i++) ans = max(ans, dp[i]);
    cout << ans << endl;
}
0