結果

問題 No.1730 GCD on Blackboard in yukicoder
ユーザー abc3abc3
提出日時 2021-11-06 02:32:38
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 299 ms / 2,000 ms
コード長 1,244 bytes
コンパイル時間 2,215 ms
コンパイル使用メモリ 197,320 KB
実行使用メモリ 8,800 KB
最終ジャッジ日時 2024-04-25 17:38:12
合計ジャッジ時間 8,102 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 299 ms
8,668 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 28 ms
7,128 KB
testcase_03 AC 28 ms
7,188 KB
testcase_04 AC 27 ms
7,048 KB
testcase_05 AC 28 ms
7,168 KB
testcase_06 AC 27 ms
7,148 KB
testcase_07 AC 27 ms
7,096 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 18 ms
6,940 KB
testcase_10 AC 19 ms
6,944 KB
testcase_11 AC 2 ms
6,944 KB
testcase_12 AC 2 ms
6,940 KB
testcase_13 AC 287 ms
8,708 KB
testcase_14 AC 296 ms
8,796 KB
testcase_15 AC 296 ms
8,704 KB
testcase_16 AC 294 ms
8,676 KB
testcase_17 AC 294 ms
8,744 KB
testcase_18 AC 273 ms
6,940 KB
testcase_19 AC 294 ms
8,800 KB
testcase_20 AC 282 ms
7,764 KB
testcase_21 AC 282 ms
7,676 KB
testcase_22 AC 290 ms
7,680 KB
testcase_23 AC 258 ms
6,940 KB
testcase_24 AC 286 ms
8,768 KB
testcase_25 AC 292 ms
8,684 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

    #include <bits/stdc++.h>
    using namespace std;
    #include <math.h>
    #include <iomanip>
    #include <cstdint>
    #include <string>
    #include <sstream>
    template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
    template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
    #define rep(i,n) for (int i = 0; i < (n); ++i)
    typedef long long ll;
    typedef long double ld;
    typedef unsigned long long ull;
    using P=pair<ll,ll>;
    const ll INF=1001001001;
    const int mod=1e9+7;
    
    void solve(){
        int n;
        cin>>n;
        vector<int>a(n);
        rep(i,n)cin>>a[i];

        int mx=*max_element(a.begin(),a.end());
        vector<int>c(mx+1);
        rep(i,n){c[a[i]]++;}
        
        vector<int>t(n+1);
        for(int i=1;i<=mx;i++){
            int cnt=0;
            for(int j=i;j<=mx;j+=i){
                cnt+=c[j];
            }
            t[n-cnt]=i;
        }
        for(int i=1;i<n;i++){chmax(t[i],t[i-1]);}

        rep(i,n){
            cout<<t[i]<<endl;
        }
    } 

    int main(){
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        
        solve();

        return 0;
    }
0