結果

問題 No.390 最長の数列
ユーザー rodearodea
提出日時 2017-12-20 13:50:25
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 657 bytes
コンパイル時間 2,679 ms
コンパイル使用メモリ 69,172 KB
実行使用メモリ 8,344 KB
最終ジャッジ日時 2023-08-22 10:51:19
合計ジャッジ時間 11,025 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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

int main()
{
	int n, x[100000], dp[100000], a, i, j = 2, k, count = 1, max = 0;

	cin >> n;

	for (i = 1; i <= n; i++)
	{
		cin >> x[i];
		dp[i] = 0;
	}

	sort(x, x + n + 1);

	if (x[1] == 1) a = 2;
	else a = 1;

	for (i = a; i <= n; i++)
	{
		if (dp[i] == 1) continue;

		while (x[i] * j<= x[n])
		{
			for (k = i + 1; k <= n; k++)
			{
				if (x[i] * j == x[k])
				{
					dp[k] = 1;
					count++;
					j = 2;
					x[i] = x[k];
					break;
				}
				if (n == k && x[i] != x[k]) j++;
			}
		}

		if (count > max)
		{
			max = count;
		}

		count = 0;
		j = 2;
	}

	cout << max + a - 1 << endl;
}
0