結果

問題 No.1730 GCD on Blackboard in yukicoder
ユーザー srjywrdnprktsrjywrdnprkt
提出日時 2023-06-03 00:37:02
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 795 bytes
コンパイル時間 1,161 ms
コンパイル使用メモリ 107,456 KB
実行使用メモリ 12,548 KB
最終ジャッジ日時 2023-08-28 07:05:22
合計ジャッジ時間 27,455 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 AC 5 ms
10,532 KB
testcase_02 AC 5 ms
10,544 KB
testcase_03 AC 5 ms
10,732 KB
testcase_04 AC 6 ms
10,692 KB
testcase_05 AC 6 ms
10,532 KB
testcase_06 AC 6 ms
10,744 KB
testcase_07 AC 6 ms
10,640 KB
testcase_08 AC 5 ms
10,760 KB
testcase_09 AC 5 ms
10,656 KB
testcase_10 AC 6 ms
10,636 KB
testcase_11 AC 5 ms
10,660 KB
testcase_12 AC 5 ms
10,528 KB
testcase_13 AC 1,782 ms
12,324 KB
testcase_14 AC 1,782 ms
12,364 KB
testcase_15 AC 1,777 ms
12,392 KB
testcase_16 AC 1,785 ms
12,336 KB
testcase_17 AC 1,787 ms
12,352 KB
testcase_18 AC 968 ms
12,340 KB
testcase_19 TLE -
testcase_20 AC 470 ms
12,360 KB
testcase_21 AC 469 ms
12,284 KB
testcase_22 TLE -
testcase_23 AC 292 ms
12,464 KB
testcase_24 AC 288 ms
12,364 KB
testcase_25 AC 1,593 ms
12,368 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;

vector<ll> cnt(1e6+1);

void all_factor(ll n){
    for (ll i = 1; i*i <= n; i++){
        if (n % i == 0){
            cnt[i]++;
            if (i*i != n) cnt[n/i]++;
        }
    }
}

int main(){

    ll N, A;
    cin >> N;
    for (int i=0; i<N; i++){
        cin >> A;
        all_factor(A);
    }
    vector<ll> ans(N+1);
    for (int i=1; i<=1e6; i++){
        ans[max(N-cnt[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