結果
問題 | No.390 最長の数列 |
ユーザー | le_panda_noir |
提出日時 | 2020-06-13 18:34:18 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 1,202 ms / 5,000 ms |
コード長 | 724 bytes |
コンパイル時間 | 965 ms |
コンパイル使用メモリ | 94,372 KB |
実行使用メモリ | 21,260 KB |
最終ジャッジ日時 | 2023-09-08 00:39:10 |
合計ジャッジ時間 | 6,394 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,376 KB |
testcase_01 | AC | 1 ms
4,380 KB |
testcase_02 | AC | 2 ms
4,376 KB |
testcase_03 | AC | 2 ms
4,380 KB |
testcase_04 | AC | 1 ms
4,380 KB |
testcase_05 | AC | 760 ms
21,260 KB |
testcase_06 | AC | 1,202 ms
8,004 KB |
testcase_07 | AC | 1 ms
4,376 KB |
testcase_08 | AC | 1 ms
4,376 KB |
testcase_09 | AC | 1 ms
4,380 KB |
testcase_10 | AC | 599 ms
15,544 KB |
testcase_11 | AC | 601 ms
15,392 KB |
testcase_12 | AC | 608 ms
15,720 KB |
testcase_13 | AC | 260 ms
6,992 KB |
testcase_14 | AC | 403 ms
8,008 KB |
testcase_15 | AC | 2 ms
4,376 KB |
testcase_16 | AC | 1 ms
4,380 KB |
testcase_17 | AC | 26 ms
4,652 KB |
testcase_18 | AC | 41 ms
5,052 KB |
ソースコード
#include <iostream> #include <algorithm> #include <vector> #include <map> using namespace std; using vi = vector<int>; void ins() {} template<class T,class... Rest>void ins(T& v,Rest&... rest){cin>>v;ins(rest...);} #define rep(i,n) for(int i=0,_i=(n);i<_i;++i) #define all(f,c,...) (([&](decltype((c)) cccc) { return (f)(begin(cccc), end(cccc), ## __VA_ARGS__); })(c)) int main() { int N; ins(N); vi x(N); rep(i, N) { cin >> x[i]; } all(sort, x); map<int, int> dp; int ans = 0; rep(i, N) { for (int j = 1; j * j <= x[i]; ++j) { if (x[i] % j == 0) dp[x[i]] = max(dp[x[i]], max(dp[j]+1, dp[x[i]/j]+1)); } ans = max(ans, dp[x[i]]); } cout << ans << endl; return 0; }