結果

問題 No.1730 GCD on Blackboard in yukicoder
ユーザー tonyu0tonyu0
提出日時 2022-04-26 00:06:06
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 62 ms / 2,000 ms
コード長 995 bytes
コンパイル時間 939 ms
コンパイル使用メモリ 97,212 KB
実行使用メモリ 12,016 KB
最終ジャッジ日時 2024-04-25 17:58:15
合計ジャッジ時間 3,556 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 54 ms
9,856 KB
testcase_01 AC 27 ms
9,308 KB
testcase_02 AC 25 ms
9,344 KB
testcase_03 AC 24 ms
9,696 KB
testcase_04 AC 27 ms
10,236 KB
testcase_05 AC 29 ms
10,724 KB
testcase_06 AC 24 ms
9,960 KB
testcase_07 AC 24 ms
9,696 KB
testcase_08 AC 23 ms
9,308 KB
testcase_09 AC 24 ms
9,440 KB
testcase_10 AC 23 ms
9,948 KB
testcase_11 AC 21 ms
9,304 KB
testcase_12 AC 26 ms
9,436 KB
testcase_13 AC 62 ms
12,016 KB
testcase_14 AC 62 ms
11,784 KB
testcase_15 AC 60 ms
11,796 KB
testcase_16 AC 60 ms
11,776 KB
testcase_17 AC 60 ms
11,648 KB
testcase_18 AC 50 ms
9,836 KB
testcase_19 AC 47 ms
10,496 KB
testcase_20 AC 54 ms
11,120 KB
testcase_21 AC 52 ms
10,732 KB
testcase_22 AC 57 ms
9,856 KB
testcase_23 AC 45 ms
9,964 KB
testcase_24 AC 48 ms
9,716 KB
testcase_25 AC 60 ms
10,224 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <cmath>
#include <iostream>
#include <numeric>
#include <queue>
#include <vector>
using namespace std;
using ll = long long;
#define rep(i, j, n) for (int i = j; i < (n); ++i)
#define rrep(i, j, n) for (int i = (n)-1; j <= i; --i)
#define all(a) a.begin(), a.end()
template <typename T>
std::ostream &operator<<(std::ostream &os, std::vector<T> &a) {
  for (size_t i = 0; i < a.size(); ++i) os << (i > 0 ? " " : "") << a[i];
  return os << '\n';
}
template <typename T>
std::istream &operator>>(std::istream &is, std::vector<T> &a) {
  for (T &x : a) { is >> x; }
  return is;
}
constexpr int N = 1000010;
int b[N], c[N];

int main() {
  cin.tie(0)->sync_with_stdio(0);
  int n;
  cin >> n;
  vector<int> a(n);
  cin >> a;
  rep(i, 0, n) b[a[i]]++;
  rep(i, 2, N) for (int j = i * 2; j < N; j += i) b[i] += b[j];
  rep(i, 0, N) c[n - b[i]] = max(c[n - b[i]], i);
  rep(i, 1, N) c[i] = max(c[i], c[i - 1]);
  rep(i, 0, n) cout << max(1, c[i]) << '\n';
  return 0;
}
0