結果

問題 No.979 Longest Divisor Sequence
ユーザー oxyshoweroxyshower
提出日時 2020-02-01 15:32:01
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 959 bytes
コンパイル時間 1,798 ms
コンパイル使用メモリ 169,972 KB
実行使用メモリ 12,576 KB
最終ジャッジ日時 2023-10-19 00:03:54
合計ジャッジ時間 5,553 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
10,080 KB
testcase_01 AC 4 ms
5,732 KB
testcase_02 AC 4 ms
5,732 KB
testcase_03 WA -
testcase_04 AC 5 ms
5,732 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 5 ms
5,732 KB
testcase_08 AC 5 ms
5,732 KB
testcase_09 AC 5 ms
5,732 KB
testcase_10 WA -
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

template<class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template<class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template<class T, class V>
typename enable_if<is_class<T>::value == 0>::type fill(T &t, const V &v) {
    t = v;
}
template<class T, class V>
typename enable_if<is_class<T>::value != 0>::type fill(T &t, const V &v){
    for (auto &e : t) fill(e, v);
}
// auto v = make_vec<int>(h, w);
// fill(v, 0);

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[i] + 1);
    }
  }
  cout << *max_element(dp.begin(),dp.end()) << endl;

  return 0;
}
0