結果

問題 No.2218 Multiple LIS
ユーザー stoq
提出日時 2022-01-29 12:51:28
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 152 ms / 3,000 ms
コード長 580 bytes
コンパイル時間 2,088 ms
コンパイル使用メモリ 194,872 KB
最終ジャッジ日時 2025-01-27 17:47:19
ジャッジサーバーID
(参考情報)
judge3 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 39
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

template <typename T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (auto &&t : a) cin >> t;
  vector<int> dp(100010, 0);
  for (int i = 0; i < n; i++) {
    int Max = 0;
    for (int d = 1; d * d <= a[i]; d++) {
      if (a[i] % d != 0) continue;
      chmax(Max, dp[d]);
      chmax(Max, dp[a[i] / d]);
    }
    dp[a[i]] = Max + 1;
  }
  cout << *max_element(begin(dp), end(dp)) << "\n";
}
0