結果

問題 No.390 最長の数列
ユーザー aaaaaa
提出日時 2018-11-09 18:23:23
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,362 bytes
コンパイル時間 978 ms
コンパイル使用メモリ 101,996 KB
実行使用メモリ 13,888 KB
最終ジャッジ日時 2024-05-01 04:17:59
合計ジャッジ時間 7,555 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
9,424 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 2 ms
5,376 KB
testcase_05 TLE -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>

using namespace std;


int main(){
	int i, j;
	int n;
	vector<int>list;

	cin >> n;

	for (i = 0; i < n; i++) {
		int num;
		cin >> num;
		list.push_back(num);
	}

	sort(list.begin(), list.end());

//	vector<vector<int>>dp(10005, vector<int>(10005, 0));
	vector<int>dp(100005, -1);



	for (i = 0; i < n; i++) {

		//dp[i][i] = max(1, dp[i][i]);
		dp[i] = max(1, dp[i]);

		for (j = 0; j < n; j++) {
			if (list[j] <= list[i])continue;

			if (list[j] % list[i] == 0) {
				//dp[i + 1][j] = max(dp[i][j], dp[i][i] + 1);
				
				//if (list[i] == list[j]) {
				//	//dp[j]++;
				//}
				//else {
				//if (dp[i] != -1) {
					dp[j] = max(dp[j], dp[i] + 1);
				//}

				if (list[i] == list[j]) {
					//dp[j]++;
					//dp[i] = max(1, dp[i]);
				}

				//}
			}
			else {
				//dp[i + 1][j] = dp[i][j];
			}
		}
	}

	int maxn = 0;

	for (i = 0; i < dp.size(); i++) {
		maxn = max(maxn, dp[i]);
	}
	cout << maxn << endl;

	//cout << dp[n] << endl;
	//cout << dp[n][n-1]-1 << endl;















	getchar();
	getchar();
	return 0;
}
0