結果
| 問題 |
No.390 最長の数列
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-09-05 09:28:22 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 50 ms / 5,000 ms |
| コード長 | 470 bytes |
| コンパイル時間 | 2,432 ms |
| コンパイル使用メモリ | 197,596 KB |
| 最終ジャッジ日時 | 2025-01-14 07:01:57 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 15 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(int)(n); i++)
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
vector<int> x(n);
REP (i, n) cin >> x[i];
sort(x.begin(), x.end());
vector<int> dp(1000000+1);
int ret = 0;
for (int a: x) {
ret = max(ret, ++dp[a]);
for (int b = 2 * a; b <= 1000000; b += a)
dp[b] = max(dp[b], dp[a]);
}
cout << ret << endl;
return 0;
}