結果

問題 No.390 最長の数列
ユーザー aaaaaa
提出日時 2018-11-09 17:13:11
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 998 bytes
コンパイル時間 935 ms
コンパイル使用メモリ 103,536 KB
実行使用メモリ 395,088 KB
最終ジャッジ日時 2024-05-01 04:17:29
合計ジャッジ時間 11,128 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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, 0);



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

		dp[i][i] = max(1, dp[i][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);
				//dp[j] = max(dp[j], dp[i] + 1);
			}
			else {
				dp[i + 1][j] = dp[i][j];
			}
		}
	}



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















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