結果

問題 No.979 Longest Divisor Sequence
ユーザー firiexpfiriexp
提出日時 2020-01-31 22:05:08
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 488 ms / 2,000 ms
コード長 969 bytes
コンパイル時間 1,057 ms
コンパイル使用メモリ 99,792 KB
実行使用メモリ 39,180 KB
最終ジャッジ日時 2023-07-25 08:57:20
合計ジャッジ時間 9,737 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 449 ms
36,792 KB
testcase_01 AC 415 ms
36,688 KB
testcase_02 AC 417 ms
37,056 KB
testcase_03 AC 424 ms
36,792 KB
testcase_04 AC 420 ms
36,828 KB
testcase_05 AC 414 ms
36,752 KB
testcase_06 AC 403 ms
36,940 KB
testcase_07 AC 421 ms
36,760 KB
testcase_08 AC 439 ms
37,072 KB
testcase_09 AC 422 ms
36,684 KB
testcase_10 AC 429 ms
36,752 KB
testcase_11 AC 438 ms
37,020 KB
testcase_12 AC 412 ms
36,752 KB
testcase_13 AC 462 ms
39,180 KB
testcase_14 AC 488 ms
39,164 KB
testcase_15 AC 460 ms
37,596 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>
#include <limits>

static constexpr int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    cin >> n;
    int M = 300001;
    vector<vector<int>> B(M);
    vector<int> v(n);
    for (auto &&k : v) scanf("%d", &k);
    vector<int> dp(n, 1), dp2(M, 0);
    for (int i = 1; i < M; ++i) {
        for (int j = 2*i; j < M; j += i) {
            B[j].emplace_back(i);
        }
    }
    for (int i = 0; i < n; ++i) {
        dp2[v[i]] = max(dp2[v[i]], 1);
        for (auto &&j : B[v[i]]) {
            dp2[v[i]] = max(dp2[v[i]], dp2[j]+1);
        }
    }
    cout << *max_element(dp2.begin(),dp2.end()) << "\n";
    return 0;
}
0