結果

問題 No.979 Longest Divisor Sequence
ユーザー oxyshoweroxyshower
提出日時 2020-02-01 15:34:19
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 450 bytes
コンパイル時間 1,538 ms
コンパイル使用メモリ 169,744 KB
実行使用メモリ 12,532 KB
最終ジャッジ日時 2023-10-19 00:05:10
合計ジャッジ時間 5,293 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

signed main(){

  int n; cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }

  vector<int> dp(3e5+1, 0);
  for(int i = 0; i < n; i++){
    for(int j = a[i]*2; j <= 3e5; j+=a[i]){
      dp[j] = max(dp[j], dp[a[i]] + 1);
    }
  }
  cout << *max_element(dp.begin(),dp.end()) << endl;

  return 0;
}
0