結果

問題 No.390 最長の数列
ユーザー CleyLCleyL
提出日時 2022-07-30 12:24:57
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 336 ms / 5,000 ms
コード長 1,916 bytes
コンパイル時間 1,026 ms
コンパイル使用メモリ 114,016 KB
実行使用メモリ 7,496 KB
最終ジャッジ日時 2023-09-27 14:49:12
合計ジャッジ時間 3,656 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
7,040 KB
testcase_01 AC 4 ms
7,040 KB
testcase_02 AC 4 ms
6,944 KB
testcase_03 AC 4 ms
6,948 KB
testcase_04 AC 3 ms
7,072 KB
testcase_05 AC 336 ms
7,408 KB
testcase_06 AC 213 ms
7,380 KB
testcase_07 AC 4 ms
6,932 KB
testcase_08 AC 4 ms
6,928 KB
testcase_09 AC 3 ms
6,932 KB
testcase_10 AC 246 ms
7,496 KB
testcase_11 AC 237 ms
7,452 KB
testcase_12 AC 236 ms
7,264 KB
testcase_13 AC 172 ms
7,252 KB
testcase_14 AC 94 ms
7,312 KB
testcase_15 AC 4 ms
7,176 KB
testcase_16 AC 4 ms
7,052 KB
testcase_17 AC 15 ms
6,976 KB
testcase_18 AC 22 ms
7,052 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

//yukicoder@cpp17

#include <iostream>

#include <cmath>
#include <algorithm>

#include <iomanip>

#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>

#include <bitset>

#include <complex>

#include <cctype>
#include <utility>
#include <climits>

#include <numeric>

using namespace std;
using ll = long long;
using P = pair<ll,ll>;

const ll MOD = 998244353;
const ll MODx = 1000000007;
const int INF = (1<<30)-1;
const ll LINF = (1LL<<62LL)-1;
const double EPS = (1e-10);

P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};




template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }
 
 /*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる

計算量は変わらないが楽できるシリーズ
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる
*/

/*
function corner below
*/


/*
Function corner above
*/

__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}

int main(){
    int n;cin>>n;
    vector<int> X(1001000);
    vector<int> A(n);
    for(int i = 0; n > i; i++){
        cin>>A[i];
    }
    sort(A.begin(),A.end());
    for(int i = 0; n > i; i++){
        int x = A[i];
        int mx = 0;
        for(int j = 1; x >= j*j; j++){
            if(x%j == 0){
                mx = max(mx,X[j]);
                if(x/j != j)mx = max(mx,X[x/j]);
            }
        }
        X[x] = mx+1;
    }
    int ans = 0;
    for(int i = 0; 1000001 > i; i++){
        ans = max(ans,X[i]);
    }
    cout << ans << endl;
}
0