結果

問題 No.2218 Multiple LIS
ユーザー siman
提出日時 2023-02-19 11:06:14
言語 C++17(clang)
(17.0.6 + boost 1.87.0)
結果
MLE  
実行時間 -
コード長 863 bytes
コンパイル時間 1,525 ms
コンパイル使用メモリ 141,692 KB
実行使用メモリ 710,144 KB
最終ジャッジ日時 2024-07-20 12:53:18
合計ジャッジ時間 27,194 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 28 MLE * 1 -- * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

#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