結果
問題 | No.2218 Multiple LIS |
ユーザー |
![]() |
提出日時 | 2023-02-17 22:11:44 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 98 ms / 3,000 ms |
コード長 | 749 bytes |
コンパイル時間 | 2,864 ms |
コンパイル使用メモリ | 140,944 KB |
実行使用メモリ | 14,592 KB |
最終ジャッジ日時 | 2024-07-19 13:21:28 |
合計ジャッジ時間 | 6,841 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 39 |
ソースコード
#include <iostream> #include <vector> #include <algorithm> #include <atcoder/all> #define ALL(V) std::begin(V), std::end(V) const int SIZE = 1e5 + 10; template <typename T> void chmax(T &a, const T &b) { a = std::max(a, b); } int main() { std::vector<std::vector<int>> divs(SIZE); for (int i = 1; i < SIZE; i++) { for (int j = 1; i * j < SIZE; j++) { divs[i * j].push_back(i); } } int N; std::cin >> N; std::vector<int> A(N); for (auto &e : A) std::cin >> e; std::vector<int> dp(SIZE); for (auto e : A) { int v = 0; for (auto d : divs[e]) chmax(v, dp[d] + 1); chmax(dp[e], v); } std::cout << *std::max_element(ALL(dp)) << std::endl; return 0; }