結果

問題 No.390 最長の数列
ユーザー kurenai3110kurenai3110
提出日時 2016-08-19 07:55:39
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 496 bytes
コンパイル時間 597 ms
コンパイル使用メモリ 65,660 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-25 09:08:57
合計ジャッジ時間 3,714 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 3 ms
5,376 KB
testcase_05 RE -
testcase_06 RE -
testcase_07 AC 2 ms
5,376 KB
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 WA -
testcase_15 AC 2 ms
5,376 KB
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)

int DP[100001];

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 = 2*x[i]; j < 100001;j+=x[i]) {
			DP[j] = max(DP[j],resource+1);
		}
	}

	int mx = 0;
	for (int i = 0; i < 100001; i++) {
		mx = max(mx, DP[i]);
	}

	cout << mx << endl;

	return 0;
}
0