結果

問題 No.2218 Multiple LIS
コンテスト
ユーザー siman
提出日時 2023-02-19 11:06:14
言語 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
結果
MLE  
実行時間 -
コード長 863 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 5,770 ms
コンパイル使用メモリ 150,544 KB
実行使用メモリ 2,608,128 KB
最終ジャッジ日時 2026-04-02 23:50:07
合計ジャッジ時間 23,573 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 28 MLE * 2 -- * 9
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <cassert>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <climits>
#include <map>
#include <queue>
#include <set>
#include <cstring>
#include <vector>

using namespace std;
typedef long long ll;

vector<int> V[100010];

int main() {
  int N;
  cin >> N;

  bool checked[100010];
  memset(checked, false, sizeof(checked));

  vector<int> A(N);
  for (int i = 0; i < N; ++i) {
    cin >> A[i];

    int a = A[i];
    while (a < 100010) {
      V[a].push_back(A[i]);
      a += A[i];
    }
  }

  int dp[100010];
  memset(dp, 0, sizeof(dp));
  int ans = 0;

  for (int a : A) {
    int temp[100010];
    memcpy(temp, dp, sizeof(dp));

    for (int v : V[a]) {
      temp[a] = max(temp[a], dp[v] + 1);
      ans = max(ans, temp[a]);
    }

    memcpy(dp, temp, sizeof(temp));
  }

  cout << ans << endl;

  return 0;
}
0