結果
問題 | No.979 Longest Divisor Sequence |
ユーザー |
![]() |
提出日時 | 2020-02-01 15:32:01 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 959 bytes |
コンパイル時間 | 1,737 ms |
コンパイル使用メモリ | 168,720 KB |
実行使用メモリ | 13,568 KB |
最終ジャッジ日時 | 2024-09-18 20:02:49 |
合計ジャッジ時間 | 5,368 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 8 WA * 5 TLE * 1 -- * 2 |
ソースコード
#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; }