結果

問題 No.2218 Multiple LIS
コンテスト
ユーザー vjudge1
提出日時 2024-02-23 11:12:28
言語 C++17(clang)
(clang++ 22.1.2 + boost 1.89.0)
コンパイル:
clang++ -O2 -lm -std=c++1z -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 65 ms / 3,000 ms
コード長 468 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 7,725 ms
コンパイル使用メモリ 172,972 KB
実行使用メモリ 7,972 KB
最終ジャッジ日時 2026-04-15 15:39:37
合計ジャッジ時間 8,729 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 39
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>

using namespace std;

const int N = 1e5 + 5;

int n, ans, a[N], dp[N];

int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= sqrt(1.0 * a[i]); j++) {
      if (a[i] % j == 0) {
        dp[a[i]] = max({dp[a[i]], dp[j] + 1, dp[a[i] / j] + 1});
      }
    }
    ans = max(ans, dp[a[i]]);
  }
  cout << ans;
  return 0;
}
0