結果

問題 No.2218 Multiple LIS
ユーザー cho435cho435
提出日時 2023-02-17 21:55:53
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 317 ms / 3,000 ms
コード長 602 bytes
コンパイル時間 3,234 ms
コンパイル使用メモリ 208,440 KB
実行使用メモリ 6,568 KB
最終ジャッジ日時 2023-09-26 19:13:29
合計ジャッジ時間 7,336 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,384 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 13 ms
4,376 KB
testcase_22 AC 95 ms
4,848 KB
testcase_23 AC 177 ms
5,468 KB
testcase_24 AC 30 ms
4,384 KB
testcase_25 AC 202 ms
5,660 KB
testcase_26 AC 309 ms
6,568 KB
testcase_27 AC 317 ms
6,380 KB
testcase_28 AC 310 ms
6,432 KB
testcase_29 AC 303 ms
6,524 KB
testcase_30 AC 311 ms
6,520 KB
testcase_31 AC 63 ms
4,380 KB
testcase_32 AC 63 ms
4,384 KB
testcase_33 AC 63 ms
4,384 KB
testcase_34 AC 64 ms
4,376 KB
testcase_35 AC 63 ms
4,380 KB
testcase_36 AC 19 ms
4,376 KB
testcase_37 AC 179 ms
4,380 KB
testcase_38 AC 2 ms
4,380 KB
testcase_39 AC 2 ms
4,376 KB
testcase_40 AC 158 ms
4,380 KB
testcase_41 AC 157 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<int(n);i++)

vector<int> div(int x){
  vector<int> rt;
  for(int i=1;i*i<=x;i++){
    if(x%i==0){
      rt.push_back(i);
      if(i*i!=x) rt.push_back(x/i);
    }
  }
  return rt;
}

int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  rep(i,n) cin>>a.at(i);
  map<int,int> mp;
  rep(i,n){
    vector<int> d=div(a.at(i));
    int nw=0;
    for(int x:d){
      if(mp.count(x)) nw=max(nw,mp.at(x));
    }
    mp[a.at(i)]=nw+1;
  }
  int ans=0;
  for(auto [dv,sc]:mp) ans=max(ans,sc);
  cout<<ans<<'\n';
}
0