結果

問題 No.1730 GCD on Blackboard in yukicoder
ユーザー srjywrdnprktsrjywrdnprkt
提出日時 2023-06-03 00:48:10
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 374 ms / 2,000 ms
コード長 732 bytes
コンパイル時間 1,612 ms
コンパイル使用メモリ 108,748 KB
実行使用メモリ 20,416 KB
最終ジャッジ日時 2023-08-28 07:10:51
合計ジャッジ時間 9,393 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 360 ms
20,416 KB
testcase_01 AC 48 ms
18,632 KB
testcase_02 AC 48 ms
18,556 KB
testcase_03 AC 47 ms
18,760 KB
testcase_04 AC 47 ms
18,552 KB
testcase_05 AC 49 ms
18,488 KB
testcase_06 AC 46 ms
18,676 KB
testcase_07 AC 45 ms
18,976 KB
testcase_08 AC 45 ms
18,744 KB
testcase_09 AC 47 ms
18,580 KB
testcase_10 AC 46 ms
18,824 KB
testcase_11 AC 45 ms
18,860 KB
testcase_12 AC 45 ms
18,868 KB
testcase_13 AC 371 ms
20,400 KB
testcase_14 AC 373 ms
20,232 KB
testcase_15 AC 374 ms
20,364 KB
testcase_16 AC 369 ms
20,236 KB
testcase_17 AC 371 ms
20,320 KB
testcase_18 AC 353 ms
20,328 KB
testcase_19 AC 359 ms
20,304 KB
testcase_20 AC 345 ms
20,328 KB
testcase_21 AC 351 ms
20,224 KB
testcase_22 AC 361 ms
20,128 KB
testcase_23 AC 323 ms
20,376 KB
testcase_24 AC 327 ms
20,340 KB
testcase_25 AC 351 ms
20,252 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;
using ll = long long;

int main(){

    ll N, A;
    cin >> N;
    vector<ll> cnt(1e6+1), sm(1e6+1);
    for (int i=0; i<N; i++){
        cin >> A;
        cnt[A]++;
    }
    for (int i=1; i<=1e6; i++){
        for (int j=i; j<=1e6; j+=i) sm[i] += cnt[j];
    }
    vector<ll> ans(N+1);
    for (int i=1; i<=1e6; i++){
        ans[max(N-sm[i], 0LL)] = i;
    }

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

    return 0;
}
0