結果

問題 No.390 最長の数列
ユーザー Ai3ShotaAi3Shota
提出日時 2018-05-11 04:16:02
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 612 bytes
コンパイル時間 2,338 ms
コンパイル使用メモリ 146,420 KB
実行使用メモリ 9,936 KB
最終ジャッジ日時 2023-09-10 12:14:49
合計ジャッジ時間 7,952 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#define MOD 1000000007

using namespace std;

int N;
int num[100001] = {0};
int dp[1000001] = {0};

int main(void){
    
    cin >> N;
    
    int i, j;
    for(i = 0; i < N; ++i){
        cin >> num[i];
    }
    sort(num, num + N);
    
    for(i = 0; i < N; ++i) dp[num[i]] = 1;
    
    for(i = 0; i < N; ++i){
        for(j = 0; j < i; ++j){
            if(num[i] % num[j] == 0) dp[num[i]] = max(dp[num[i]], dp[num[j]] + 1); 
        }
    }
    
    int result = 0;
    for(i = 0; i < N; ++i) result = max(result, dp[num[i]]);
    
    cout << result << endl;
    
    return 0;
}
0