結果

問題 No.390 最長の数列
ユーザー nksk38nksk38
提出日時 2017-08-01 23:17:53
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,006 bytes
コンパイル時間 839 ms
コンパイル使用メモリ 90,208 KB
実行使用メモリ 54,400 KB
最終ジャッジ日時 2024-04-19 07:50:20
合計ジャッジ時間 3,508 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 WA -
testcase_05 AC 93 ms
8,832 KB
testcase_06 AC 80 ms
12,544 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 WA -
testcase_11 AC 185 ms
19,200 KB
testcase_12 WA -
testcase_13 AC 1,169 ms
54,400 KB
testcase_14 AC 100 ms
8,832 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 14 ms
8,320 KB
testcase_18 AC 21 ms
8,960 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
#include<limits>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ll, string> pls;

#define MAX_N 1000000

int n;
int a[100010];
int used[MAX_N+1];
map<int, int> m;

int main()
{
	cin >> n;

	int mx = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		m[a[i]] = 1;
		mx = max(mx,a[i]);
	}

	sort(a, a + n);

	int num, num_mx = 0,x;
	for (int i = 0; i < n - num_mx; i++) {
		if (a[i] == 1)continue;
		if (used[a[i]])continue;
		x = a[i];
		num = 0;
		for (int j = 1; x * j <= mx; j++) {
			if (m[x * j]) {
				used[x*j] = 1;
				num++;
				x = x*j;
				j = 1;
			}
		}
		num_mx = max(num_mx, num);
	}
	if (a[0] == 1)num_mx++;
	cout << num_mx << endl;
	return 0;
}
0