結果
| 問題 | No.390 最長の数列 | 
| コンテスト | |
| ユーザー |  kurenai3110 | 
| 提出日時 | 2016-08-19 07:58:45 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 66 ms / 5,000 ms | 
| コード長 | 496 bytes | 
| コンパイル時間 | 1,079 ms | 
| コンパイル使用メモリ | 66,064 KB | 
| 実行使用メモリ | 7,552 KB | 
| 最終ジャッジ日時 | 2024-10-02 11:55:48 | 
| 合計ジャッジ時間 | 1,751 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 15 | 
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int DP[1000001];
int main() {
	int n;
	cin >> n;
	vector<int> x;
	x.resize(n);
	rep(i, n) {
		cin >> x[i];
	}
	sort(x.begin(), x.end());
	rep(i, n) {
		int resource = DP[x[i]];
		for (int j = x[i]; j < 1000001;j+=x[i]) {
			DP[j] = max(DP[j],resource+1);
		}
	}
	int mx = 0;
	for (int i = 0; i < 1000001; i++) {
		mx = max(mx, DP[i]);
	}
	cout << mx << endl;
	return 0;
}
            
            
            
        