結果

問題 No.390 最長の数列
ユーザー Grun1396
提出日時 2017-02-21 10:04:18
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 572 bytes
コンパイル時間 858 ms
コンパイル使用メモリ 59,228 KB
実行使用メモリ 8,960 KB
最終ジャッジ日時 2024-12-30 12:27:35
合計ジャッジ時間 38,075 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 8 WA * 1 TLE * 6
権限があれば一括ダウンロードができます

ソースコード

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