結果

問題 No.2218 Multiple LIS
ユーザー vjudge1vjudge1
提出日時 2023-08-29 10:55:29
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 726 bytes
コンパイル時間 1,968 ms
コンパイル使用メモリ 201,340 KB
実行使用メモリ 11,220 KB
最終ジャッジ日時 2023-08-29 10:55:52
合計ジャッジ時間 21,791 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,760 KB
testcase_01 AC 4 ms
5,960 KB
testcase_02 AC 4 ms
5,764 KB
testcase_03 AC 3 ms
5,716 KB
testcase_04 AC 4 ms
5,716 KB
testcase_05 AC 3 ms
5,684 KB
testcase_06 AC 4 ms
5,708 KB
testcase_07 AC 4 ms
5,756 KB
testcase_08 AC 3 ms
5,772 KB
testcase_09 AC 3 ms
5,676 KB
testcase_10 AC 3 ms
5,704 KB
testcase_11 AC 4 ms
5,760 KB
testcase_12 AC 3 ms
5,728 KB
testcase_13 AC 3 ms
5,716 KB
testcase_14 AC 3 ms
5,692 KB
testcase_15 AC 4 ms
5,688 KB
testcase_16 AC 3 ms
5,704 KB
testcase_17 AC 4 ms
5,688 KB
testcase_18 AC 3 ms
5,836 KB
testcase_19 AC 4 ms
5,676 KB
testcase_20 AC 3 ms
5,776 KB
testcase_21 AC 9 ms
5,936 KB
testcase_22 AC 43 ms
7,152 KB
testcase_23 AC 71 ms
7,784 KB
testcase_24 AC 16 ms
6,184 KB
testcase_25 AC 79 ms
7,788 KB
testcase_26 AC 118 ms
8,480 KB
testcase_27 AC 121 ms
8,488 KB
testcase_28 AC 124 ms
8,472 KB
testcase_29 AC 121 ms
8,440 KB
testcase_30 AC 120 ms
8,516 KB
testcase_31 AC 2,666 ms
6,816 KB
testcase_32 AC 2,677 ms
6,660 KB
testcase_33 AC 2,685 ms
6,688 KB
testcase_34 AC 2,683 ms
6,920 KB
testcase_35 AC 2,695 ms
6,800 KB
testcase_36 TLE -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
using LL = long long;

const int MAXN = 1e5 + 3;

int n;
int a[MAXN];
int dp[MAXN];
vector<int> s[MAXN];

int main(){
  ios::sync_with_stdio(0), cin.tie(0);
  cin >> n;
  for(int i = 1; i <= n; i++){
    cin >> a[i], dp[i] = 1;
    s[a[i]].push_back(i);
  }
  int ans = 0;
  for(int i = n; i >= 1; i--){
    s[a[i]].pop_back();
    for(int j = 1; j * j <= a[i]; j++){
      if(a[i] % j == 0){
        for(int id : s[j]){
          dp[id] = max(dp[id], dp[i] + 1);
        }
        if(a[i] / j != j){
          for(int id : s[a[i] / j]){
            dp[id] = max(dp[id], dp[i] + 1);
          }
        }
      }
    }
    ans = max(ans, dp[i]);
  }
  cout << ans;
  return 0;
}
0