結果

問題 No.390 最長の数列
ユーザー rapurasurapurasu
提出日時 2016-07-13 15:21:19
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 589 bytes
コンパイル時間 1,744 ms
コンパイル使用メモリ 168,452 KB
実行使用メモリ 9,460 KB
最終ジャッジ日時 2024-04-22 16:28:31
合計ジャッジ時間 8,342 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,248 KB
testcase_02 AC 2 ms
5,248 KB
testcase_03 AC 1 ms
5,248 KB
testcase_04 AC 2 ms
5,376 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>
 using namespace std;
#define INF 1000000000
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)

vector<int> A;
int dp[100001];
int main(){
    long long int N;
    cin>>N;
    REP(i,N){
        int a;
        cin>>a;
        A.push_back(a);
    }
    REP(i,N){
        dp[i]=1;
    }
    sort(A.begin(),A.end());

    for(int i=0;i<N;i++){
        for(int j=0;j<i;j++){
            if((A[i]%A[j])==0){
                dp[i]=max(dp[i],dp[j]+1);
            }
        }
    }
    int m=0;
    for(int i=0;i<N;i++){
        m=max(dp[i],m);
    }
    cout<<m<<endl;
}
0