結果

問題 No.2218 Multiple LIS
ユーザー vjudge1vjudge1
提出日時 2023-08-29 12:10:41
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 739 bytes
コンパイル時間 3,438 ms
コンパイル使用メモリ 167,488 KB
実行使用メモリ 814,320 KB
最終ジャッジ日時 2023-08-29 12:10:50
合計ジャッジ時間 6,851 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
9,460 KB
testcase_01 AC 5 ms
9,468 KB
testcase_02 AC 5 ms
9,660 KB
testcase_03 AC 4 ms
9,404 KB
testcase_04 AC 4 ms
9,468 KB
testcase_05 AC 4 ms
9,476 KB
testcase_06 AC 5 ms
9,464 KB
testcase_07 AC 5 ms
9,400 KB
testcase_08 AC 5 ms
9,432 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 5 ms
9,408 KB
testcase_13 AC 6 ms
9,664 KB
testcase_14 AC 6 ms
9,656 KB
testcase_15 AC 5 ms
9,580 KB
testcase_16 AC 5 ms
9,500 KB
testcase_17 AC 5 ms
9,704 KB
testcase_18 WA -
testcase_19 AC 5 ms
9,496 KB
testcase_20 AC 5 ms
9,656 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 40 ms
10,300 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 333 ms
19,632 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 MLE -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
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],ans;
vector<long long> w[kMaxN],s[kMaxN];
void F(long long x){
  for(long long i=1;i*i<=x;i++){
    if(x%i==0){
      if(w[i].size()){
        for(long long j:w[i]){
          s[x].push_back(j);
        }
        if(i*i!=x&&w[x/i].size()){
          for(long long j:w[x/i]){
            s[x].push_back(j);
          }
        }
      }
    }
  }
}
int main(){
  cin>>n;
  for(long long i=1;i<=n;i++){
    cin>>a[i];
    d[i]=1,w[a[i]].push_back(i);
    F(a[i]);
  }
  for(long long i=1;i<=n;i++){
    for(long long j:s[a[i]]){
      if(j<i){
        d[i]=max(d[i],d[j]+1);
      }
    }
    ans=max(ans,d[i]);
  }
  cout<<ans;
  return 0;
}
0