結果

問題 No.2218 Multiple LIS
ユーザー vjudge1
提出日時 2024-02-22 10:20:00
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 125 ms / 3,000 ms
コード長 558 bytes
コンパイル時間 1,301 ms
コンパイル使用メモリ 170,492 KB
実行使用メモリ 13,940 KB
最終ジャッジ日時 2024-09-29 04:24:59
合計ジャッジ時間 6,609 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 39
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>

using namespace std;

const int INF = 1e5;
const int N = 1e5 + 5;

vector<int> g[N];
int n, dp[N], num[N];

int main(){
  for(int i = 1; i <= INF; i++){
    for(int j = 1; j * j <= i; j++){
      if(i % j == 0){
        g[i].push_back(j);
        if(j * j != i){
          g[i].push_back(i / j);
        }
      }
    }
  }
  cin >> n;
  for(int i = 1, x; i <= n; i++){
    cin >> x;
    for(int v : g[x]){
      dp[i] = max(dp[i], num[v] + 1);
    }
    num[x] = dp[i];
  }
  cout << *max_element(dp + 1, dp + n + 1);
  return 0;
}
0