結果

問題 No.1884 Sequence
ユーザー taisii2taisii2
提出日時 2022-03-25 21:47:06
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 164 ms / 2,000 ms
コード長 842 bytes
コンパイル時間 1,752 ms
コンパイル使用メモリ 171,636 KB
実行使用メモリ 7,144 KB
最終ジャッジ日時 2024-04-22 06:27:48
合計ジャッジ時間 6,582 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 163 ms
7,016 KB
testcase_11 AC 164 ms
7,016 KB
testcase_12 AC 29 ms
6,944 KB
testcase_13 AC 32 ms
6,944 KB
testcase_14 AC 30 ms
6,940 KB
testcase_15 AC 94 ms
6,940 KB
testcase_16 AC 149 ms
7,016 KB
testcase_17 AC 67 ms
6,940 KB
testcase_18 AC 92 ms
6,944 KB
testcase_19 AC 75 ms
6,944 KB
testcase_20 AC 82 ms
6,944 KB
testcase_21 AC 64 ms
6,940 KB
testcase_22 AC 89 ms
6,944 KB
testcase_23 AC 148 ms
7,012 KB
testcase_24 AC 149 ms
7,016 KB
testcase_25 AC 142 ms
7,016 KB
testcase_26 AC 147 ms
7,108 KB
testcase_27 AC 36 ms
6,944 KB
testcase_28 AC 36 ms
6,940 KB
testcase_29 AC 36 ms
6,944 KB
testcase_30 AC 36 ms
6,944 KB
testcase_31 AC 77 ms
6,944 KB
testcase_32 AC 137 ms
7,012 KB
testcase_33 AC 132 ms
7,140 KB
testcase_34 AC 133 ms
6,996 KB
testcase_35 AC 43 ms
6,944 KB
testcase_36 AC 101 ms
6,944 KB
testcase_37 AC 133 ms
7,144 KB
testcase_38 AC 120 ms
7,016 KB
testcase_39 AC 57 ms
6,944 KB
testcase_40 AC 62 ms
6,944 KB
testcase_41 AC 122 ms
7,020 KB
testcase_42 AC 121 ms
7,016 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<long long> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  sort(A.begin(), A.end());
  vector<long long> B;
  int cnt0 = 0;
  for (int i = 0; i < N - 1; i++) {
    if (A[i] != 0) {
      B.push_back(A[i + 1] - A[i]);
    } else {
      cnt0++;
    }
  }
  sort(B.begin(), B.end());
  bool ok = false;
  if (B.empty()) {
    ok = true;
  } else if (B[0] == 0) {
    if (B.back() == 0) {
      ok = true;
    }
  } else {
    long long g = B[0];
    for (int i = 0; i < B.size(); i++) {
      g = __gcd(g, B[i]);
    }
    long long c = 0;
    for (int i = 0; i < B.size(); i++) {
      c += B[i] / g - 1;
    }
    if (cnt0 >= c) {
      ok = true;
    }
  }
  if (ok) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}
0