結果

問題 No.390 最長の数列
ユーザー nanophoto12nanophoto12
提出日時 2017-09-10 10:33:40
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,110 bytes
コンパイル時間 940 ms
コンパイル使用メモリ 96,260 KB
実行使用メモリ 22,912 KB
最終ジャッジ日時 2024-04-25 02:54:42
合計ジャッジ時間 7,691 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
22,912 KB
testcase_01 AC 8 ms
11,264 KB
testcase_02 AC 8 ms
11,264 KB
testcase_03 AC 8 ms
11,136 KB
testcase_04 AC 8 ms
11,264 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 <cmath>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <functional>
#include <queue>
#include <iostream>
#include <string.h>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cstdint>
#include <climits>
#include <unordered_set>
#include <sstream>
#include <stack>

using namespace std;

typedef long long int ll;
typedef tuple<int,int,int> t3;


using namespace std;

int vs[1000100];
int l[1000100];
int dp[1000100];
vector<int> t;

void solve()
{
    int n;
    cin >> n;
    fill(vs, vs + 1000100, -1);
    fill(l, l + 1000100, -1);
    t.resize(n);
    for(int i = 0;i < n;i++)
    {
        int a;
        cin >> a;
        vs[a] = i;
        t[i] = a;
    }
    sort(t.begin(), t.end());
    int m = 1;
    for(int i = n-1;i >= 0;i--)
    {
        dp[t[i]] = 1;
        for(int j = i +1;j < n;j++)
        {
            if(t[j] % t[i] == 0)
            {
                dp[t[i]] = max(dp[t[i]], 1 + dp[t[j]]);
                m = max(m, dp[t[i]]);
            }
        }
    }
    cout << m << endl;
}

int main()
{
    solve();
    return 0;
}
0