結果
問題 | No.1730 GCD on Blackboard in yukicoder |
ユーザー | noya2 |
提出日時 | 2021-11-05 21:39:02 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 1,122 ms / 2,000 ms |
コード長 | 1,434 bytes |
コンパイル時間 | 2,286 ms |
コンパイル使用メモリ | 201,552 KB |
実行使用メモリ | 17,636 KB |
最終ジャッジ日時 | 2024-04-25 17:17:44 |
合計ジャッジ時間 | 15,307 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1,122 ms
17,096 KB |
testcase_01 | AC | 56 ms
15,980 KB |
testcase_02 | AC | 50 ms
15,748 KB |
testcase_03 | AC | 37 ms
16,464 KB |
testcase_04 | AC | 38 ms
16,328 KB |
testcase_05 | AC | 37 ms
16,144 KB |
testcase_06 | AC | 38 ms
16,972 KB |
testcase_07 | AC | 38 ms
16,496 KB |
testcase_08 | AC | 45 ms
16,688 KB |
testcase_09 | AC | 43 ms
15,812 KB |
testcase_10 | AC | 43 ms
16,488 KB |
testcase_11 | AC | 61 ms
17,348 KB |
testcase_12 | AC | 56 ms
16,612 KB |
testcase_13 | AC | 822 ms
16,428 KB |
testcase_14 | AC | 827 ms
16,960 KB |
testcase_15 | AC | 854 ms
17,392 KB |
testcase_16 | AC | 817 ms
16,912 KB |
testcase_17 | AC | 851 ms
17,424 KB |
testcase_18 | AC | 557 ms
17,480 KB |
testcase_19 | AC | 999 ms
17,044 KB |
testcase_20 | AC | 426 ms
17,576 KB |
testcase_21 | AC | 414 ms
16,552 KB |
testcase_22 | AC | 1,000 ms
16,816 KB |
testcase_23 | AC | 341 ms
17,636 KB |
testcase_24 | AC | 336 ms
16,632 KB |
testcase_25 | AC | 738 ms
17,536 KB |
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for (int i = 0; i < int(n); ++i) #define repp(i,n,m) for (int i = m; i < int(n); ++i) using namespace std; using P = pair<int, int>; template<class T>istream &operator>>(istream &is,vector<T> &v){for(auto &e:v)is>>e;return is;} template<class T>ostream &operator<<(ostream &os,const vector<T> &v){if(v.size()==0){os<<endl;}else{rep(i,v.size())os<<v[i]<<(i+1==v.size()?"\n":" ");}return os;} template<class T>istream &operator>>(istream &is,vector<vector<T>> &v){for(auto &e:v)is>>e;return is;} template<class T>ostream &operator<<(ostream &os,const vector<vector<T>> &v){if(v.size()==0){os<<endl;}else{for(auto &e:v)os<<e;}return os;} template<typename T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;} template<typename T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;} int main(){ int n; cin >> n; vector<int> ar(n); cin >> ar; vector<int> cnt(1000001,0); rep(i,n){ for (int d = 1; d * d <= ar[i]; d++){ if (ar[i] % d == 0){ cnt[d]++; if (d * d != ar[i]) cnt[ar[i] / d]++; } } } priority_queue<P> pque; repp(i,1000001,1) pque.push(P(cnt[i],i)); int ans = 0; rep(i,n){ while (!pque.empty() && pque.top().first >= n - i){ chmax(ans,pque.top().second); pque.pop(); } cout << ans << endl; } }