結果

問題 No.1730 GCD on Blackboard in yukicoder
ユーザー atjh16atjh16
提出日時 2021-11-05 23:35:18
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 1,902 ms / 2,000 ms
コード長 460 bytes
コンパイル時間 2,279 ms
コンパイル使用メモリ 202,664 KB
実行使用メモリ 33,408 KB
最終ジャッジ日時 2024-04-25 17:36:48
合計ジャッジ時間 23,403 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,695 ms
6,812 KB
testcase_01 AC 2 ms
6,948 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 3 ms
6,940 KB
testcase_04 AC 3 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 3 ms
6,940 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 3 ms
6,940 KB
testcase_11 AC 1 ms
6,944 KB
testcase_12 AC 1 ms
6,940 KB
testcase_13 AC 1,902 ms
22,144 KB
testcase_14 AC 1,739 ms
22,016 KB
testcase_15 AC 1,798 ms
22,016 KB
testcase_16 AC 1,751 ms
22,016 KB
testcase_17 AC 1,742 ms
22,144 KB
testcase_18 AC 934 ms
13,568 KB
testcase_19 AC 1,866 ms
33,408 KB
testcase_20 AC 663 ms
6,944 KB
testcase_21 AC 667 ms
6,940 KB
testcase_22 AC 1,550 ms
6,940 KB
testcase_23 AC 286 ms
6,944 KB
testcase_24 AC 286 ms
6,940 KB
testcase_25 AC 1,361 ms
22,272 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int n, a;
map<int, int> b;
int c[200000];

int main()
{
	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> a;

		for (int j = 1; j <= sqrt(a); j++) {
			if (a % j == 0) {
				b[j]++;

				if(j * j != a)
					b[a / j]++;
			}
		}
	}

	for (auto j : b) {
		int k = n - j.second;
		c[k] = max(c[k], j.first);
	}

	for (int i = 0; i < n; i++) {
		if(i > 0)
			c[i] = max(c[i], c[i - 1]);
		cout << c[i] << endl;
	}
}
0