結果

問題 No.2218 Multiple LIS
コンテスト
ユーザー vjudge1
提出日時 2023-08-29 10:59:51
言語 C++17
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 168 ms / 3,000 ms
コード長 638 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,480 ms
コンパイル使用メモリ 215,960 KB
実行使用メモリ 6,528 KB
最終ジャッジ日時 2026-07-02 07:53:32
合計ジャッジ時間 3,911 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 39
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include<bits/stdc++.h>
using namespace std;
const int MAXN=1e6+100,mod=1e9+7;
int n;
int a[MAXN];
struct cmp{
  bool operator()(int a, int b) const {
    return a > b;
  }
};
set<int,  cmp> p;
int dp[MAXN];
int main () {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  dp[0]=1;
  for (int i=1; i<=n; i++) {
    cin >> a[i];
    p.clear();
    for (int j=1; j*j<=a[i]; j++){
      if (a[i]%j==0) {
        p.insert(j);
        p.insert(a[i]/j);
      }
    }
    for (int j : p) {
      dp[a[i]]=max(dp[a[i]],dp[j]+1);
    }
  }
  int ans=0;
  for (int i=1; i<=n; i++) {
    ans=max(ans,dp[a[i]]);
  }
  cout << ans;
  return 0;
}
0