結果
| 問題 |
No.2218 Multiple LIS
|
| コンテスト | |
| ユーザー |
vjudge1
|
| 提出日時 | 2023-08-29 10:41:00 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 123 ms / 3,000 ms |
| コード長 | 436 bytes |
| コンパイル時間 | 1,648 ms |
| コンパイル使用メモリ | 167,960 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-12-30 23:11:54 |
| 合計ジャッジ時間 | 4,758 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 39 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
const int kMaxN=1e5+1;
int n,a[kMaxN],m[kMaxN],dp[kMaxN],ans;
int main(){
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
cin>>n;
for(int i=1;i<=n;i++){
cin>>a[i];
}
for(int i=1;i<=n;i++){
dp[i]=1;
for(int j=1;j*j<=a[i];j++){
if(a[i]%j==0){
dp[i]=max({dp[i],m[j]+1,m[a[i]/j]+1});
}
}
ans=max(ans,dp[i]);
m[a[i]]=max(m[a[i]],dp[i]);
}
cout<<ans;
return 0;
}
vjudge1