結果
| 問題 |
No.2218 Multiple LIS
|
| コンテスト | |
| ユーザー |
vjudge1
|
| 提出日時 | 2023-08-29 12:23:10 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 358 ms / 3,000 ms |
| コード長 | 446 bytes |
| コンパイル時間 | 2,152 ms |
| コンパイル使用メモリ | 191,976 KB |
| 最終ジャッジ日時 | 2025-02-16 15:31:33 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 39 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
int n, ans, a[maxn], dp[maxn];
int main(){
cin >> n;
for(int i = 1; i <= n; i++){
cin >> a[i];
// dp[a[i]] = 1;
}
for(int i = 1; i <= n; i++){
for(long long j = 1; j * j <= a[i]; j++){
if(a[i] % j == 0){
dp[a[i]] = max({dp[a[i]], dp[j] + 1, dp[a[i] / j] + 1});
}
}
ans = max(ans, dp[a[i]]);
}
cout << ans;
return 0;
}
vjudge1