結果

問題 No.2218 Multiple LIS
ユーザー vjudge1vjudge1
提出日時 2023-08-29 11:53:09
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 657 bytes
コンパイル時間 1,654 ms
コンパイル使用メモリ 168,356 KB
実行使用メモリ 22,532 KB
最終ジャッジ日時 2023-08-29 11:53:35
合計ジャッジ時間 24,413 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
9,672 KB
testcase_01 AC 4 ms
9,528 KB
testcase_02 AC 4 ms
9,528 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 4 ms
9,540 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 4 ms
9,456 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 4 ms
9,512 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 TLE -
testcase_32 TLE -
testcase_33 TLE -
testcase_34 TLE -
testcase_35 TLE -
testcase_36 TLE -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
const int kMaxN=1e5+3;
long long n,a[kMaxN],d[kMaxN],d1[kMaxN],ans,h[kMaxN],f[kMaxN];
bool w[kMaxN];
vector<long long> s[kMaxN];
void F(int x){
  for(int i=1;i*i<=x;i++){
    if(x%i==0){
      s[x].push_back(i);
      if(i*i!=x){
        s[x].push_back(x/i);
      }
    }
  }
}
int main(){
  cin>>n;
  for(int i=1;i<=n;i++){
    cin>>a[i];
    d1[a[i]]++,d[a[i]]=1,h[a[i]]=i;
    F(a[i]);
  }
  for(int i=1;i<=n;i++){
    for(int j:s[a[i]]){
      if(h[j]!=0&&h[j]<i){
        d[a[i]]=max(d[a[i]],d[j]+(w[a[i]]?0:d1[a[i]]));
      }
    }
    w[a[i]]=1;
    ans=max(ans,d[a[i]]);
  }
  cout<<ans;
  return 0;
}
0