結果

問題 No.979 Longest Divisor Sequence
ユーザー nejinejinejineji
提出日時 2020-01-31 22:14:14
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,112 bytes
コンパイル時間 2,252 ms
コンパイル使用メモリ 168,664 KB
実行使用メモリ 8,060 KB
最終ジャッジ日時 2023-10-17 10:06:25
合計ジャッジ時間 4,532 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
5,684 KB
testcase_01 AC 4 ms
5,684 KB
testcase_02 AC 4 ms
5,684 KB
testcase_03 AC 4 ms
5,684 KB
testcase_04 AC 5 ms
5,684 KB
testcase_05 AC 4 ms
5,684 KB
testcase_06 AC 4 ms
5,684 KB
testcase_07 AC 4 ms
5,684 KB
testcase_08 WA -
testcase_09 AC 4 ms
5,684 KB
testcase_10 AC 18 ms
5,684 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 49 ms
8,060 KB
testcase_14 WA -
testcase_15 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define REP(i, x, y) for (ll i = x; i <= y; i++)
#define BIT(t) (1ll << t)
#define PER(i, y, x) for (ll i = y; i >= x; i--)
#define vll vector<ll>
#define vvll vector<vector<ll>>
#define pll pair<ll, ll>
#define SIZE(v) ll(v.size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
typedef long long ll;
//        ios::sync_with_stdio(false);
//        cin.tie(nullptr);

int main(){
        ll n;
        cin >> n;
        vll a(n+1);
        ll const MAX = 3e5 + 1;
        vll v(MAX, 0);
        REP(i,1,n){
                cin >> a[i];
        }
        REP(i,1,n){
                ll t = a[i];
                if(t == 1){
                        v[1] = 1;
                        continue;
                }
                v[t] = max(v[t], v[1] + 1);
                for(ll i = 2;i * i<=t;i++){
                        ll j = t / i;
                        v[t] = max({v[t], v[i] + 1, v[j] + 1});
                }
        }
        ll ans = 0;
        REP(i,1,MAX){
                ans = max(ans, v[i]);
        }
        cout << ans << endl;
}
0