結果

問題 No.2218 Multiple LIS
ユーザー stoq
提出日時 2022-01-29 13:25:34
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 620 bytes
コンパイル時間 3,014 ms
コンパイル使用メモリ 200,284 KB
最終ジャッジ日時 2025-01-27 17:49:24
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23 TLE * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < int(n); i++)
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

template <typename T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  vector<int> dp(n, 0);
  rep(i, n) {
    rep(j, i) if (a[i] % a[j] == 0) chmax(dp[i], dp[j]);
    dp[i]++;
  }
  int ans = 0;
  rep(i, n) chmax(ans, dp[i]);
  cout << ans << "\n";
}
0