結果

問題 No.1730 GCD on Blackboard in yukicoder
ユーザー 夜
提出日時 2021-11-18 21:24:08
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 381 ms / 2,000 ms
コード長 782 bytes
コンパイル時間 828 ms
コンパイル使用メモリ 92,912 KB
実行使用メモリ 13,000 KB
最終ジャッジ日時 2024-04-25 17:51:48
合計ジャッジ時間 7,952 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 356 ms
9,544 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 25 ms
9,032 KB
testcase_03 AC 29 ms
11,336 KB
testcase_04 AC 27 ms
11,336 KB
testcase_05 AC 30 ms
11,468 KB
testcase_06 AC 26 ms
11,208 KB
testcase_07 AC 28 ms
11,464 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 21 ms
10,692 KB
testcase_10 AC 17 ms
10,100 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 2 ms
6,940 KB
testcase_13 AC 372 ms
12,996 KB
testcase_14 AC 381 ms
12,988 KB
testcase_15 AC 376 ms
12,868 KB
testcase_16 AC 367 ms
13,000 KB
testcase_17 AC 364 ms
12,964 KB
testcase_18 AC 325 ms
8,008 KB
testcase_19 AC 358 ms
11,080 KB
testcase_20 AC 325 ms
11,724 KB
testcase_21 AC 330 ms
11,616 KB
testcase_22 AC 343 ms
9,160 KB
testcase_23 AC 297 ms
6,940 KB
testcase_24 AC 320 ms
10,824 KB
testcase_25 AC 346 ms
10,564 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