結果

問題 No.2218 Multiple LIS
ユーザー vjudge1
提出日時 2025-04-18 15:59:37
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 460 bytes
コンパイル時間 1,552 ms
コンパイル使用メモリ 161,280 KB
実行使用メモリ 13,932 KB
最終ジャッジ日時 2025-04-18 15:59:42
合計ジャッジ時間 4,229 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 1
other AC * 7 WA * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define int long long

using namespace std;

const int kMaxN = 1e6 + 5;

int n, mx, c[kMaxN], f[kMaxN];

signed main() {
  cin.tie(0)->ios::sync_with_stdio(0);
  cin >> n;
  for (int i = 1, x; i <= n; i++) {
    cin >> x, c[x]++;
  }
  for (int i = 1; i <= 1e6; i++) {
    if (!c[i]) continue;
    f[i] += c[i];
    for (int j = 2 * i; j <= 1e6; j += i) {
      f[j] = max(f[j], f[i]);
    }
    mx = max(mx, f[i]);
  }
  cout << mx;
}
0