結果

問題 No.2218 Multiple LIS
ユーザー vjudge1vjudge1
提出日時 2023-08-29 11:00:20
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 297 ms / 3,000 ms
コード長 643 bytes
コンパイル時間 2,059 ms
コンパイル使用メモリ 203,468 KB
実行使用メモリ 7,972 KB
最終ジャッジ日時 2023-08-29 11:00:36
合計ジャッジ時間 5,922 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,428 KB
testcase_01 AC 2 ms
5,464 KB
testcase_02 AC 2 ms
5,536 KB
testcase_03 AC 2 ms
5,408 KB
testcase_04 AC 2 ms
5,420 KB
testcase_05 AC 2 ms
5,364 KB
testcase_06 AC 2 ms
5,372 KB
testcase_07 AC 2 ms
5,384 KB
testcase_08 AC 2 ms
5,416 KB
testcase_09 AC 2 ms
5,372 KB
testcase_10 AC 2 ms
5,688 KB
testcase_11 AC 2 ms
5,416 KB
testcase_12 AC 2 ms
5,444 KB
testcase_13 AC 3 ms
5,376 KB
testcase_14 AC 2 ms
5,416 KB
testcase_15 AC 2 ms
5,664 KB
testcase_16 AC 3 ms
5,424 KB
testcase_17 AC 2 ms
5,532 KB
testcase_18 AC 2 ms
5,528 KB
testcase_19 AC 3 ms
5,480 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 11 ms
5,764 KB
testcase_22 AC 62 ms
6,060 KB
testcase_23 AC 104 ms
7,816 KB
testcase_24 AC 24 ms
5,820 KB
testcase_25 AC 117 ms
7,916 KB
testcase_26 AC 165 ms
7,904 KB
testcase_27 AC 163 ms
7,972 KB
testcase_28 AC 162 ms
7,856 KB
testcase_29 AC 159 ms
7,880 KB
testcase_30 AC 159 ms
7,904 KB
testcase_31 AC 69 ms
7,624 KB
testcase_32 AC 71 ms
7,752 KB
testcase_33 AC 72 ms
7,608 KB
testcase_34 AC 70 ms
7,488 KB
testcase_35 AC 70 ms
7,484 KB
testcase_36 AC 12 ms
7,588 KB
testcase_37 AC 297 ms
7,460 KB
testcase_38 AC 2 ms
5,412 KB
testcase_39 AC 3 ms
5,540 KB
testcase_40 AC 172 ms
7,620 KB
testcase_41 AC 169 ms
7,552 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
const int MAXN=1e6+100,mod=1e9+7;
int n;
int a[MAXN];
struct cmp{
  bool operator()(int a, int b) const {
    return a > b;
  }
};
set<int,  cmp> p;
int dp[MAXN];
int main () {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  dp[0]=1;
  for (int i=1; i<=n; i++) {
    cin >> a[i];
    p.clear();
    for (int j=1; j*j<=a[i]; j++){
      if (a[i]%j==0) {
        p.insert(j);
        p.insert(a[i]/j);
      }
    }
    for (int j : p) {
      dp[a[i]]=max(dp[a[i]],dp[j]+1);
    }
  }
  int ans=0;
  for (int i=1; i<=n; i++) {
    ans=max(ans,dp[a[i]]);
  }
  cout << ans;
  return 0;
}
/////
0