結果
問題 | No.979 Longest Divisor Sequence |
ユーザー | chocorusk |
提出日時 | 2020-01-31 21:48:13 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 966 bytes |
コンパイル時間 | 1,041 ms |
コンパイル使用メモリ | 113,800 KB |
実行使用メモリ | 38,652 KB |
最終ジャッジ日時 | 2023-10-17 09:11:05 |
合計ジャッジ時間 | 4,799 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 31 ms
21,228 KB |
testcase_01 | AC | 37 ms
21,228 KB |
testcase_02 | AC | 39 ms
21,464 KB |
testcase_03 | AC | 37 ms
21,228 KB |
testcase_04 | WA | - |
testcase_05 | AC | 48 ms
23,140 KB |
testcase_06 | AC | 53 ms
23,396 KB |
testcase_07 | AC | 53 ms
23,396 KB |
testcase_08 | WA | - |
testcase_09 | AC | 57 ms
23,636 KB |
testcase_10 | WA | - |
testcase_11 | AC | 333 ms
34,100 KB |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | AC | 568 ms
38,588 KB |
testcase_15 | AC | 490 ms
37,724 KB |
ソースコード
#include <cstdio> #include <cstring> #include <iostream> #include <string> #include <cmath> #include <bitset> #include <vector> #include <map> #include <set> #include <queue> #include <deque> #include <algorithm> #include <complex> #include <unordered_map> #include <unordered_set> #include <random> #include <cassert> #include <fstream> #include <utility> #include <functional> #include <time.h> #include <stack> #include <array> #define popcount __builtin_popcount using namespace std; typedef long long int ll; typedef pair<int, int> P; const ll MOD=1e9+7; int main() { int n; cin>>n; int a[300030]; for(int i=0; i<n; i++){ cin>>a[i]; } vector<int> g[300030]; for(int d=1; d<=n; d++){ for(int i=2; i<=300000/d; i++){ g[d*i].push_back(d); } } int dp[300030]={}; for(int i=0; i<n; i++){ for(auto y:g[a[i]]){ dp[a[i]]=max(dp[a[i]], dp[y]+1); } } int ans=0; for(int i=1; i<=300000; i++) ans=max(ans, dp[i]); cout<<ans<<endl; return 0; }