結果
問題 |
No.390 最長の数列
|
ユーザー |
|
提出日時 | 2025-04-21 17:43:46 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 68 ms / 5,000 ms |
コード長 | 528 bytes |
コンパイル時間 | 3,463 ms |
コンパイル使用メモリ | 278,372 KB |
実行使用メモリ | 7,844 KB |
最終ジャッジ日時 | 2025-04-21 17:43:51 |
合計ジャッジ時間 | 5,012 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 15 |
ソースコード
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; int main() { int n; cin >> n; vector<int> a(n); rep(i, n) cin >> a[i]; sort(a.begin(), a.end()); const int M = 1e6; vector<int> dp(M+1); int ans = 1; rep(i, n) { int now = dp[a[i]]+1; for (int j = a[i]*2; j <= M; j += a[i]) { dp[j] = max(dp[j], now); } ans = max(ans, now); } cout << ans << '\n'; return 0; }