結果

問題 No.1730 GCD on Blackboard in yukicoder
ユーザー 👑 platinumplatinum
提出日時 2021-11-05 23:01:47
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 1,103 ms / 2,000 ms
コード長 651 bytes
コンパイル時間 2,163 ms
コンパイル使用メモリ 196,744 KB
実行使用メモリ 8,948 KB
最終ジャッジ日時 2024-04-25 17:33:18
合計ジャッジ時間 14,268 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,103 ms
8,948 KB
testcase_01 AC 5 ms
7,144 KB
testcase_02 AC 5 ms
7,324 KB
testcase_03 AC 6 ms
7,232 KB
testcase_04 AC 6 ms
7,232 KB
testcase_05 AC 5 ms
7,312 KB
testcase_06 AC 6 ms
7,264 KB
testcase_07 AC 5 ms
7,164 KB
testcase_08 AC 5 ms
7,084 KB
testcase_09 AC 5 ms
7,076 KB
testcase_10 AC 6 ms
7,104 KB
testcase_11 AC 5 ms
7,168 KB
testcase_12 AC 5 ms
7,144 KB
testcase_13 AC 769 ms
8,784 KB
testcase_14 AC 773 ms
8,744 KB
testcase_15 AC 777 ms
8,864 KB
testcase_16 AC 776 ms
8,704 KB
testcase_17 AC 775 ms
8,884 KB
testcase_18 AC 528 ms
8,704 KB
testcase_19 AC 933 ms
8,636 KB
testcase_20 AC 414 ms
8,628 KB
testcase_21 AC 399 ms
8,856 KB
testcase_22 AC 981 ms
8,636 KB
testcase_23 AC 302 ms
8,744 KB
testcase_24 AC 302 ms
8,704 KB
testcase_25 AC 712 ms
8,812 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)

using namespace std;
using LL = long long;
using P = pair<int,int>;
using vv = vector<vector<int>>;
const int INF = (int)1e9;
const LL LINF = (LL)1e18;

vector<int> res(1000010);

int main(){
	int N;
	cin >> N;
	vector<int> A(N);
	rep(i,N) cin >> A[i];
	rep(i,N){
		for(int d = 1; d * d <= A[i]; d++){
			if(A[i] % d == 0){
				res[d]++;
				if(A[i] / d != d) res[A[i] / d]++;
			}
		}
	}
	vector<int> ans(N+1);
	rep(i,1000005) res[i] = N - res[i];
	rep(i,1000005) ans[res[i]] = i;
	rep(i,N) ans[i+1] = max(ans[i+1], ans[i]);
	rep(i,N) cout << ans[i] << endl;

	return 0;
}
0