結果
| 問題 | No.390 最長の数列 | 
| コンテスト | |
| ユーザー |  Manuel1024 | 
| 提出日時 | 2022-04-06 03:45:16 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 63 ms / 5,000 ms | 
| コード長 | 511 bytes | 
| コンパイル時間 | 532 ms | 
| コンパイル使用メモリ | 72,584 KB | 
| 実行使用メモリ | 7,576 KB | 
| 最終ジャッジ日時 | 2024-11-27 14:01:03 | 
| 合計ジャッジ時間 | 2,476 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 15 | 
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    int n; cin >> n;
    vector<int> a(n);
    for(auto &it: a) cin >> it;
    vector<int> dp(1000010, 0);
    for(auto &it: a) dp[it] = 1;
    for(int i = 1000000; i > 0; i--){
        int mx = 0;
        for(int j = i*2; j < dp.size(); j += i){
            mx = max(mx, dp[j]);
        }
        dp[i] += mx;
    }
    int ans = 0;
    for(auto &it: dp) ans = max(ans, it);
    cout << ans << endl;
    return 0;
}
            
            
            
        