結果

問題 No.2218 Multiple LIS
ユーザー vjudge1
提出日時 2024-02-22 10:29:24
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 146 ms / 3,000 ms
コード長 399 bytes
コンパイル時間 1,702 ms
コンパイル使用メモリ 191,288 KB
最終ジャッジ日時 2025-02-19 18:42:47
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 39
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>

using namespace std;

const int N = 1e5 + 5;

int sum, dp[N], n, x, ans;

int O(int x){
  sum = 0;
  for(int i = 1; i * i <= x; ++i){
    if(x % i == 0){
      sum = max({dp[x / i], sum, dp[i]});
    }
  }
  return sum;
}

int main(){
  cin >> n;
  for(int i = 1; i <= n; ++i){
    cin >> x;
    dp[x] = O(x) + 1;
    ans = max(ans, dp[x]);
  }
  cout << ans;
  return 0;
}
0