結果
問題 | No.390 最長の数列 |
ユーザー | Ai3Shota |
提出日時 | 2018-05-11 04:43:18 |
言語 | C++11 (gcc 11.4.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 811 bytes |
コンパイル時間 | 1,517 ms |
コンパイル使用メモリ | 149,452 KB |
実行使用メモリ | 6,128 KB |
最終ジャッジ日時 | 2023-09-10 12:15:08 |
合計ジャッジ時間 | 4,561 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | AC | 5 ms
5,460 KB |
testcase_04 | WA | - |
testcase_05 | RE | - |
testcase_06 | RE | - |
testcase_07 | AC | 2 ms
5,464 KB |
testcase_08 | RE | - |
testcase_09 | RE | - |
testcase_10 | RE | - |
testcase_11 | RE | - |
testcase_12 | RE | - |
testcase_13 | RE | - |
testcase_14 | WA | - |
testcase_15 | AC | 59 ms
5,576 KB |
testcase_16 | RE | - |
testcase_17 | RE | - |
testcase_18 | RE | - |
ソースコード
#include <bits/stdc++.h> #define MOD 1000000007 using namespace std; int N; int num[100001] = {0}; int dp[1000001] = {0}; vector<int> divisor(int n) { if (n == 1) return {}; vector<int> res; for (int i = 1; i * i <= n; i++) { if (n % i == 0) { res.emplace_back(i); if (i != 1 && i != n / i) res.emplace_back(n / i); } } return res; } int main(void){ cin >> N; int i; for(i = 0; i < N; ++i){ cin >> num[i]; } sort(num, num + N); for(auto i : num){ dp[i] = 1; auto k = divisor(num[i]); for(auto j : k) dp[i] = max(dp[i], dp[j] + 1); } int result = 0; for(i = 0; i < N; ++i) result = max(result, dp[num[i]]); cout << result << endl; return 0; }