結果

問題 No.390 最長の数列
ユーザー rodearodea
提出日時 2019-04-14 16:41:34
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,511 bytes
コンパイル時間 1,176 ms
コンパイル使用メモリ 109,756 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-19 07:47:09
合計ジャッジ時間 4,304 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 RE -
testcase_06 RE -
testcase_07 AC 2 ms
4,348 KB
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 WA -
testcase_15 AC 2 ms
4,348 KB
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

int dx[]={1, 0, -1, 0};
int dy[]={0, -1, 0, 1};

int main(){
    int n; cin>>n;
    vector<int> x(n);
    for(int i=0; i<n; i++) cin>>x[i];
    sort(x.begin(), x.end());

    vector<int> dp(100010, 0);
    for(int i=0; i<n; i++){
        dp[x[i]] = 1;
    }

    for(int i=1; i<10005; i++){
        if(dp[i]){
            vector<int> v;
            for(int j=1; j*j<=i; j++){
                if(i % j == 0){
                    v.eb(j);
                    v.eb(i / j);
                }
            }

            for(auto j:v){
                if(i != j) dp[i] = max(dp[i], dp[j] + 1);
            }
        }
    }

    int ans=0;
    for(int i=0; i<n; i++){
        chmax(ans, dp[x[i]]);
    }

    cout << ans << endl;
}
0