結果
問題 | No.390 最長の数列 |
ユーザー |
![]() |
提出日時 | 2020-01-13 19:18:12 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 81 ms / 5,000 ms |
コード長 | 527 bytes |
コンパイル時間 | 2,153 ms |
コンパイル使用メモリ | 171,848 KB |
実行使用メモリ | 11,904 KB |
最終ジャッジ日時 | 2024-12-21 13:59:44 |
合計ジャッジ時間 | 2,875 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 15 |
ソースコード
#include<bits/stdc++.h> using namespace std; #ifdef LOCAL_DEBUG #include "LOCAL_DEBUG.hpp" #endif #define int long long signed main(){ int n; cin >> n; vector<int> a(n); for(int i = 0; i < n; i++){ cin >> a[i]; } sort(a.begin(),a.end()); vector<int> v(1000001, 1); for(int i = 0; i < n; i++){ for(int j = a[i]*2; j < 1000001; j+=a[i]){ v[j] = max(v[j], v[a[i]] + 1); } } int ans = 0; for(int i = 0; i < n; i++){ ans = max(ans, v[a[i]]); } cout << ans << endl; return 0; }