結果

問題 No.390 最長の数列
ユーザー Grun1396Grun1396
提出日時 2017-02-21 10:04:18
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 572 bytes
コンパイル時間 607 ms
コンパイル使用メモリ 61,100 KB
実行使用メモリ 8,264 KB
最終ジャッジ日時 2023-08-28 22:20:09
合計ジャッジ時間 7,439 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 WA -
testcase_05 AC 37 ms
4,380 KB
testcase_06 TLE -
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 <iostream>
#include <algorithm>
#define MAX_N 100000
using namespace std;

int main(){
	int x[MAX_N] = {0};
	int n;
	cin >> n;

	for(int d = 0; d < n; d++){
		cin >> x[d];
	}

	//
	sort(x,x+n);
	int max = x[n-1];
	int ans = 1;
	int count = 1;
	int tmp = 0;

	for(int d = 0; d < n; d++){
		tmp = d;
		for(int e = 1; e < n; e++){
			if(2 * x[tmp] > max) break;//次の数列の要素はないのでストップ
			if(x[e] % x[tmp] == 0){
				count++;
				tmp = e;
			}
		}
		if(count > ans){ ans = count;}//更新
		count = 0;
	}

	cout << ans << endl;
	return 0;
}
0