結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 RE -
testcase_04 RE -
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 146 ms
7,632 KB
testcase_11 AC 142 ms
7,680 KB
testcase_12 AC 25 ms
4,624 KB
testcase_13 AC 27 ms
4,380 KB
testcase_14 AC 26 ms
4,376 KB
testcase_15 AC 83 ms
6,060 KB
testcase_16 AC 132 ms
7,736 KB
testcase_17 AC 57 ms
5,720 KB
testcase_18 AC 81 ms
6,376 KB
testcase_19 AC 65 ms
6,172 KB
testcase_20 AC 71 ms
5,792 KB
testcase_21 AC 54 ms
5,452 KB
testcase_22 AC 77 ms
6,240 KB
testcase_23 AC 133 ms
7,744 KB
testcase_24 AC 133 ms
7,628 KB
testcase_25 AC 127 ms
7,808 KB
testcase_26 AC 132 ms
7,836 KB
testcase_27 RE -
testcase_28 RE -
testcase_29 AC 32 ms
4,576 KB
testcase_30 AC 31 ms
4,640 KB
testcase_31 AC 67 ms
5,576 KB
testcase_32 AC 124 ms
7,680 KB
testcase_33 AC 118 ms
7,776 KB
testcase_34 AC 118 ms
7,680 KB
testcase_35 AC 37 ms
5,040 KB
testcase_36 AC 87 ms
6,704 KB
testcase_37 AC 119 ms
7,772 KB
testcase_38 AC 107 ms
7,736 KB
testcase_39 AC 49 ms
5,320 KB
testcase_40 AC 54 ms
5,276 KB
testcase_41 AC 107 ms
7,052 KB
testcase_42 AC 107 ms
7,184 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();
  assert(K != 1);

  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);
  if (zerocnt > 0)
  {
    cout << (zerocnt == K - 1 ? "Yes" : "No") << endl;
    return 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