結果

問題 No.1884 Sequence
ユーザー miscalcmiscalc
提出日時 2022-03-07 14:34:51
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 809 bytes
コンパイル時間 2,347 ms
コンパイル使用メモリ 206,012 KB
実行使用メモリ 8,236 KB
最終ジャッジ日時 2023-09-29 15:20:50
合計ジャッジ時間 8,459 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 RE -
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 RE -
testcase_06 RE -
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 RE -
testcase_10 AC 142 ms
7,808 KB
testcase_11 AC 142 ms
7,684 KB
testcase_12 AC 25 ms
4,376 KB
testcase_13 AC 27 ms
4,380 KB
testcase_14 AC 26 ms
4,396 KB
testcase_15 AC 84 ms
6,436 KB
testcase_16 AC 132 ms
7,960 KB
testcase_17 AC 56 ms
5,912 KB
testcase_18 AC 81 ms
6,432 KB
testcase_19 AC 65 ms
5,832 KB
testcase_20 AC 71 ms
5,892 KB
testcase_21 AC 54 ms
5,332 KB
testcase_22 AC 77 ms
6,048 KB
testcase_23 AC 133 ms
7,736 KB
testcase_24 AC 133 ms
7,668 KB
testcase_25 AC 127 ms
7,836 KB
testcase_26 AC 133 ms
7,724 KB
testcase_27 AC 30 ms
4,640 KB
testcase_28 AC 30 ms
4,636 KB
testcase_29 AC 31 ms
4,588 KB
testcase_30 AC 31 ms
4,640 KB
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 RE -
testcase_37 RE -
testcase_38 RE -
testcase_39 RE -
testcase_40 RE -
testcase_41 AC 107 ms
6,888 KB
testcase_42 AC 108 ms
6,828 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main()
{
  int N;
  cin >> N;
  vector<ll> A(N);
  for (int i = 0; i < N; i++)
  {
    cin >> A.at(i);
  }

  vector<ll> C;
  for (int i = 0; i < N; i++)
  {
    if (A.at(i) != 0)
      C.push_back(A.at(i));
  }
  int K = C.size();
  if (K == 0)
  {
    cout << "Yes" << endl;
    return 0;
  }

  sort(C.begin(), C.end());
  vector<ll> D(K - 1);
  for (int i = 0; i < K - 1; i++)
  {
    D.at(i) = C.at(i + 1) - C.at(i);
  }

  int zerocnt = count(D.begin(), D.end(), 0LL);
  assert(zerocnt == 0);

  ll g = 0;
  for (int i = 0; i < K - 1; i++)
  {
    g = gcd(g, D.at(i));
  }

  ll need = 0;
  for (int i = 0; i < K - 1; i++)
  {
    ll tmp = D.at(i) / g - 1;
    need += tmp;
  }

  cout << (need <= N - K ? "Yes" : "No") << endl;
}
0