結果

問題 No.1730 GCD on Blackboard in yukicoder
ユーザー 夜
提出日時 2021-11-18 21:24:08
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 359 ms / 2,000 ms
コード長 782 bytes
コンパイル時間 765 ms
コンパイル使用メモリ 91,848 KB
実行使用メモリ 12,912 KB
最終ジャッジ日時 2023-08-07 23:40:48
合計ジャッジ時間 7,586 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 345 ms
9,404 KB
testcase_01 AC 1 ms
5,456 KB
testcase_02 AC 24 ms
8,768 KB
testcase_03 AC 25 ms
10,720 KB
testcase_04 AC 25 ms
10,752 KB
testcase_05 AC 25 ms
10,816 KB
testcase_06 AC 25 ms
10,724 KB
testcase_07 AC 25 ms
10,780 KB
testcase_08 AC 3 ms
5,388 KB
testcase_09 AC 14 ms
9,560 KB
testcase_10 AC 15 ms
9,760 KB
testcase_11 AC 2 ms
5,392 KB
testcase_12 AC 2 ms
5,396 KB
testcase_13 AC 359 ms
12,712 KB
testcase_14 AC 357 ms
12,912 KB
testcase_15 AC 355 ms
12,716 KB
testcase_16 AC 355 ms
12,708 KB
testcase_17 AC 356 ms
12,740 KB
testcase_18 AC 318 ms
7,108 KB
testcase_19 AC 349 ms
11,672 KB
testcase_20 AC 318 ms
10,464 KB
testcase_21 AC 316 ms
10,560 KB
testcase_22 AC 334 ms
10,436 KB
testcase_23 AC 291 ms
6,368 KB
testcase_24 AC 312 ms
9,456 KB
testcase_25 AC 338 ms
9,796 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int co[1000010] = {}, a[200020];
int d[1000010] = {};
int ans[200020] = {};
int main() {
	int n;
	cin >> n;
	int m = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		m = max(m, a[i]);
		d[a[i]]++;
	}
	int co1 = 0;
	for (int i = 2; i <= m; i++) {
		for (int j = i; j <= m; j += i) {
			co1++;
			co[i] += d[j];
		}
	}
	for (int i = 2; i <= m; i++) {
		ans[min(n, co[i])] = i;
	}
	ans[n + 1] = 1;
	for (int i = n; i > 0; i--) {
		ans[i] = max(ans[i], ans[i + 1]);
		cout << ans[i] << endl;
	}
}
0