結果

問題 No.1730 GCD on Blackboard in yukicoder
ユーザー tonyu0tonyu0
提出日時 2022-04-26 00:03:42
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 987 bytes
コンパイル時間 865 ms
コンパイル使用メモリ 95,040 KB
実行使用メモリ 11,972 KB
最終ジャッジ日時 2023-09-10 06:31:33
合計ジャッジ時間 6,074 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 55 ms
9,796 KB
testcase_01 AC 25 ms
9,472 KB
testcase_02 AC 26 ms
9,216 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 25 ms
9,316 KB
testcase_12 AC 26 ms
9,340 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 55 ms
9,552 KB
testcase_23 AC 46 ms
9,748 KB
testcase_24 WA -
testcase_25 WA -
権限があれば一括ダウンロードができます

ソースコード

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 << c[i] << '\n';
  return 0;
}
0