結果

問題 No.390 最長の数列
ユーザー jajagacchijajagacchi
提出日時 2017-01-01 01:49:48
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 571 bytes
コンパイル時間 704 ms
コンパイル使用メモリ 61,144 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-22 09:05:58
合計ジャッジ時間 2,055 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <stdio.h>
#include <algorithm>

int main()
{
	int N; std::cin >> N;
	int *x = new int[N];
	int *dp = new int[N];
	for(int i=0;i<N;i++)
	{
		std::cin >> x[i];
	}
	std::sort(x , x+N);
	dp[0] = 1;
	int last = x[0];
	int M = 0;
	for(int i=1;i<N;i++)
	{
		//dp[i] = dp[i-1]+1 or dp[i-1];
		if(x[i]%last==0)
		{
			dp[i] = dp[i-1]+1;
			last = x[i];
		}
		else
		{
			dp[i] = dp[i-1];
		}
	}
// 	for(int i=0;i<N;i++)
// 	{
// 		printf("dp[%d] = %d\n" , i , dp[i]);
// 	}
	std::cout << dp[N-1] << std::endl;

	delete[] x;
	delete[] dp;

	return 0;
}
0