結果

問題 No.1730 GCD on Blackboard in yukicoder
ユーザー simansiman
提出日時 2023-08-03 21:57:48
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
AC  
実行時間 364 ms / 2,000 ms
コード長 832 bytes
コンパイル時間 1,365 ms
コンパイル使用メモリ 142,956 KB
実行使用メモリ 8,760 KB
最終ジャッジ日時 2024-04-21 20:44:38
合計ジャッジ時間 8,890 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 352 ms
8,664 KB
testcase_01 AC 3 ms
7,320 KB
testcase_02 AC 28 ms
7,268 KB
testcase_03 AC 28 ms
7,380 KB
testcase_04 AC 28 ms
7,236 KB
testcase_05 AC 28 ms
7,260 KB
testcase_06 AC 28 ms
7,328 KB
testcase_07 AC 28 ms
7,348 KB
testcase_08 AC 4 ms
7,336 KB
testcase_09 AC 19 ms
7,324 KB
testcase_10 AC 20 ms
7,228 KB
testcase_11 AC 4 ms
7,368 KB
testcase_12 AC 3 ms
7,264 KB
testcase_13 AC 362 ms
8,512 KB
testcase_14 AC 364 ms
8,684 KB
testcase_15 AC 362 ms
8,576 KB
testcase_16 AC 364 ms
8,596 KB
testcase_17 AC 360 ms
8,636 KB
testcase_18 AC 317 ms
8,500 KB
testcase_19 AC 347 ms
8,628 KB
testcase_20 AC 328 ms
8,732 KB
testcase_21 AC 318 ms
8,728 KB
testcase_22 AC 342 ms
8,500 KB
testcase_23 AC 287 ms
8,724 KB
testcase_24 AC 312 ms
8,760 KB
testcase_25 AC 340 ms
8,728 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cassert>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <climits>
#include <map>
#include <queue>
#include <set>
#include <cstring>
#include <vector>

using namespace std;
typedef long long ll;

int main() {
  int N;
  cin >> N;

  int counter[1000010];
  memset(counter, 0, sizeof(counter));

  int a_max = 0;
  int A[N];
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
    counter[A[i]]++;
    a_max = max(a_max, A[i]);
  }

  vector<int> ans(N, 1);
  for (int i = 2; i <= a_max; ++i) {
    int v = 0;

    for (int j = i; j <= a_max; j += i) {
      v += counter[j];
    }

    if (v != 0) {
      ans[N - v] = i;
    }
  }

  for (int i = 1; i < N; ++i) {
    ans[i] = max(ans[i], ans[i - 1]);
  }

  for (int i = 0; i < N; ++i) {
    cout << ans[i] << endl;
  }

  return 0;
}
0