結果

問題 No.1730 GCD on Blackboard in yukicoder
ユーザー 沙耶花沙耶花
提出日時 2021-11-07 14:33:12
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 356 ms / 2,000 ms
コード長 557 bytes
コンパイル時間 4,985 ms
コンパイル使用メモリ 259,608 KB
実行使用メモリ 8,004 KB
最終ジャッジ日時 2023-08-07 23:35:28
合計ジャッジ時間 11,447 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 356 ms
7,808 KB
testcase_01 AC 28 ms
7,056 KB
testcase_02 AC 28 ms
6,892 KB
testcase_03 AC 28 ms
7,124 KB
testcase_04 AC 28 ms
6,928 KB
testcase_05 AC 29 ms
6,920 KB
testcase_06 AC 29 ms
6,952 KB
testcase_07 AC 29 ms
6,984 KB
testcase_08 AC 29 ms
6,972 KB
testcase_09 AC 29 ms
6,884 KB
testcase_10 AC 29 ms
7,048 KB
testcase_11 AC 29 ms
7,200 KB
testcase_12 AC 29 ms
6,928 KB
testcase_13 AC 350 ms
7,788 KB
testcase_14 AC 355 ms
7,776 KB
testcase_15 AC 344 ms
7,760 KB
testcase_16 AC 348 ms
7,776 KB
testcase_17 AC 343 ms
7,780 KB
testcase_18 AC 338 ms
7,812 KB
testcase_19 AC 342 ms
7,736 KB
testcase_20 AC 339 ms
7,844 KB
testcase_21 AC 337 ms
7,772 KB
testcase_22 AC 352 ms
7,844 KB
testcase_23 AC 320 ms
8,004 KB
testcase_24 AC 319 ms
7,848 KB
testcase_25 AC 344 ms
7,684 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000001


int main(){
	
	int n;
	cin>>n;
	
	vector<int> a(1000001,0);
	rep(i,n){
		int x;
		cin>>x;
		a[x]++;
	}
	
	for(int i=1;i<=1000000;i++){
		for(int j=i*2;j<=1000000;j+=i){
			a[i] += a[j];
		}
	}
	
	vector<int> ans(n+1,0);
	rep(i,a.size()){
		ans[n-a[i]] = i;
	}
	int as = 0;
	rep(i,n){
		as = max(as,ans[i]);
		cout<<as<<endl;
	}
	
	return 0;
}
0