結果

問題 No.2218 Multiple LIS
ユーザー FplusFplusFFplusFplusF
提出日時 2023-02-17 21:58:53
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,285 bytes
コンパイル時間 3,016 ms
コンパイル使用メモリ 205,148 KB
実行使用メモリ 12,348 KB
最終ジャッジ日時 2023-09-26 19:16:33
合計ジャッジ時間 13,467 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
9,772 KB
testcase_01 AC 3 ms
5,356 KB
testcase_02 AC 3 ms
5,440 KB
testcase_03 AC 4 ms
5,404 KB
testcase_04 AC 4 ms
5,356 KB
testcase_05 AC 3 ms
5,344 KB
testcase_06 AC 3 ms
5,404 KB
testcase_07 AC 2 ms
5,344 KB
testcase_08 AC 3 ms
5,460 KB
testcase_09 AC 4 ms
5,452 KB
testcase_10 AC 3 ms
5,296 KB
testcase_11 AC 3 ms
5,532 KB
testcase_12 AC 5 ms
5,344 KB
testcase_13 AC 7 ms
5,392 KB
testcase_14 AC 6 ms
5,472 KB
testcase_15 AC 6 ms
5,352 KB
testcase_16 AC 5 ms
5,348 KB
testcase_17 AC 6 ms
5,388 KB
testcase_18 AC 3 ms
5,668 KB
testcase_19 AC 4 ms
5,364 KB
testcase_20 AC 6 ms
5,524 KB
testcase_21 AC 6 ms
5,692 KB
testcase_22 AC 23 ms
6,932 KB
testcase_23 AC 42 ms
8,060 KB
testcase_24 AC 11 ms
5,988 KB
testcase_25 AC 44 ms
7,932 KB
testcase_26 AC 70 ms
9,108 KB
testcase_27 AC 70 ms
9,224 KB
testcase_28 AC 70 ms
9,104 KB
testcase_29 AC 67 ms
9,172 KB
testcase_30 AC 68 ms
9,104 KB
testcase_31 AC 1,049 ms
8,144 KB
testcase_32 AC 1,038 ms
7,988 KB
testcase_33 AC 1,039 ms
8,036 KB
testcase_34 AC 1,046 ms
8,044 KB
testcase_35 AC 1,054 ms
7,912 KB
testcase_36 TLE -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (long long i=0;i<(long long)(n);i++)
#define all(v) v.begin(),v.end()
using ll=long long;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll,ll>;
const ll INF=(1ll<<60);
template<class T> void chmin(T &a,T b){
    if(a>b){
        a=b;
    }
}
template<class T> void chmax(T &a,T b){
    if(a<b){
        a=b;
    }
}
int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    vector<vector<ll>> b(1e5+1);
    ll mx=0;
    rep(i,n){
        cin >> a[i];
        chmax(mx,a[i]);
        b[a[i]].push_back(i);
    }
    vector<ll> dp(n,1);
    rep(i,n){
        if(20<=a[i]){
            for(ll j=a[i];j<=mx;j+=a[i]){
                auto itr=upper_bound(all(b[j]),i);
                if(itr==b[j].end()) continue;
                chmax(dp[(*itr)],dp[i]+1);
            }
        }
        for(ll j=a[i];j<=2e4;j+=a[i]){
            auto itr=upper_bound(all(b[j]),i);
            if(itr==b[j].end()) continue;
            chmax(dp[(*itr)],dp[i]+1);
        }
        for(ll j=(mx+a[i]-1)/a[i];8e4<=j;j-=a[i]){
            auto itr=upper_bound(all(b[j]),i);
            if(itr==b[j].end()) continue;
            chmax(dp[(*itr)],dp[i]+1);
        }
    }
    ll ans=1;
    rep(i,n) chmax(ans,dp[i]);
    cout << ans << endl;
}
0