結果

問題 No.1730 GCD on Blackboard in yukicoder
ユーザー srjywrdnprktsrjywrdnprkt
提出日時 2023-01-16 15:52:48
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 380 ms / 2,000 ms
コード長 765 bytes
コンパイル時間 958 ms
コンパイル使用メモリ 107,804 KB
実行使用メモリ 20,508 KB
最終ジャッジ日時 2023-08-29 22:45:09
合計ジャッジ時間 10,426 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 369 ms
20,456 KB
testcase_01 AC 48 ms
18,556 KB
testcase_02 AC 49 ms
19,008 KB
testcase_03 AC 47 ms
18,744 KB
testcase_04 AC 48 ms
18,688 KB
testcase_05 AC 48 ms
18,804 KB
testcase_06 AC 48 ms
18,812 KB
testcase_07 AC 48 ms
18,500 KB
testcase_08 AC 48 ms
18,924 KB
testcase_09 AC 47 ms
18,800 KB
testcase_10 AC 49 ms
18,808 KB
testcase_11 AC 47 ms
18,492 KB
testcase_12 AC 49 ms
18,612 KB
testcase_13 AC 378 ms
20,264 KB
testcase_14 AC 376 ms
20,272 KB
testcase_15 AC 380 ms
20,400 KB
testcase_16 AC 372 ms
20,268 KB
testcase_17 AC 372 ms
20,508 KB
testcase_18 AC 362 ms
20,408 KB
testcase_19 AC 357 ms
20,136 KB
testcase_20 AC 353 ms
20,316 KB
testcase_21 AC 336 ms
20,188 KB
testcase_22 AC 356 ms
20,196 KB
testcase_23 AC 326 ms
20,256 KB
testcase_24 AC 324 ms
20,224 KB
testcase_25 AC 362 ms
20,500 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <iomanip>
#include <queue>
#include <algorithm>
#include <numeric>
#include <deque>
#include <complex>
#include <cassert>

using namespace std;

int main(){

    long long N, A;
    cin >> N;
    vector<long long> cnt(1e6+1), tot(1e6+1), ans(N+1);
    for (int i=0; i<N; i++){
        cin >> A;
        cnt[A]++;
    }

    for (int i=1; i<=1000000; i++){
        for (int j=i; j<=1000000; j+=i) tot[i] += cnt[j];
    }

    for (int i=1000000; i>=0; i--){
        if (N-tot[i]>=0) ans[N-tot[i]] = max(ans[N-tot[i]], (long long)i);
    }

    for (int i=0; i<N; i++) ans[i+1] = max(ans[i], ans[i+1]);

    for (int i=0; i<N; i++) cout << ans[i] << endl;

    return 0;
}
0