結果

問題 No.2218 Multiple LIS
ユーザー SSRSSSRS
提出日時 2023-02-17 21:24:41
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 105 ms / 3,000 ms
コード長 549 bytes
コンパイル時間 1,858 ms
コンパイル使用メモリ 169,224 KB
実行使用メモリ 14,228 KB
最終ジャッジ日時 2023-09-26 18:29:08
合計ジャッジ時間 7,979 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
13,972 KB
testcase_01 AC 69 ms
13,736 KB
testcase_02 AC 75 ms
13,868 KB
testcase_03 AC 74 ms
13,816 KB
testcase_04 AC 72 ms
13,904 KB
testcase_05 AC 67 ms
13,808 KB
testcase_06 AC 64 ms
13,912 KB
testcase_07 AC 63 ms
13,908 KB
testcase_08 AC 65 ms
13,880 KB
testcase_09 AC 67 ms
13,860 KB
testcase_10 AC 64 ms
13,916 KB
testcase_11 AC 67 ms
13,792 KB
testcase_12 AC 67 ms
13,860 KB
testcase_13 AC 69 ms
13,816 KB
testcase_14 AC 70 ms
13,860 KB
testcase_15 AC 63 ms
13,792 KB
testcase_16 AC 68 ms
13,964 KB
testcase_17 AC 68 ms
13,916 KB
testcase_18 AC 65 ms
13,856 KB
testcase_19 AC 68 ms
13,968 KB
testcase_20 AC 67 ms
13,860 KB
testcase_21 AC 69 ms
13,812 KB
testcase_22 AC 76 ms
13,808 KB
testcase_23 AC 86 ms
14,080 KB
testcase_24 AC 72 ms
13,908 KB
testcase_25 AC 86 ms
14,012 KB
testcase_26 AC 95 ms
14,180 KB
testcase_27 AC 105 ms
14,124 KB
testcase_28 AC 101 ms
14,076 KB
testcase_29 AC 99 ms
14,176 KB
testcase_30 AC 101 ms
14,176 KB
testcase_31 AC 87 ms
14,172 KB
testcase_32 AC 87 ms
14,120 KB
testcase_33 AC 86 ms
14,008 KB
testcase_34 AC 87 ms
14,072 KB
testcase_35 AC 89 ms
14,120 KB
testcase_36 AC 81 ms
14,124 KB
testcase_37 AC 101 ms
14,076 KB
testcase_38 AC 66 ms
13,796 KB
testcase_39 AC 64 ms
13,808 KB
testcase_40 AC 90 ms
14,172 KB
testcase_41 AC 94 ms
14,228 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
const int MAX = 100000;
int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++){
    cin >> A[i];
  }
  vector<vector<int>> F(MAX + 1);
  for (int i = 1; i <= MAX; i++){
    for (int j = i; j <= MAX; j += i){
      F[j].push_back(i);
    }
  }
  vector<int> dp(MAX + 1, 0);
  int ans = 0;
  for (int i = 0; i < N; i++){
    int tmp = 0;
    for (int j : F[A[i]]){
      tmp = max(tmp, dp[j] + 1);
    }
    dp[A[i]] = tmp;
    ans = max(ans, tmp);
  }
  cout << ans << endl;
}
0