結果

問題 No.1884 Sequence
ユーザー taisii2taisii2
提出日時 2022-03-25 21:47:06
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 137 ms / 2,000 ms
コード長 842 bytes
コンパイル時間 1,564 ms
コンパイル使用メモリ 172,552 KB
実行使用メモリ 6,980 KB
最終ジャッジ日時 2023-08-04 08:39:42
合計ジャッジ時間 6,374 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 137 ms
6,768 KB
testcase_11 AC 137 ms
6,616 KB
testcase_12 AC 23 ms
4,380 KB
testcase_13 AC 27 ms
4,384 KB
testcase_14 AC 24 ms
4,492 KB
testcase_15 AC 81 ms
5,884 KB
testcase_16 AC 127 ms
6,620 KB
testcase_17 AC 57 ms
5,344 KB
testcase_18 AC 76 ms
5,616 KB
testcase_19 AC 61 ms
5,340 KB
testcase_20 AC 67 ms
5,736 KB
testcase_21 AC 54 ms
5,488 KB
testcase_22 AC 75 ms
5,668 KB
testcase_23 AC 128 ms
6,612 KB
testcase_24 AC 124 ms
6,672 KB
testcase_25 AC 121 ms
6,624 KB
testcase_26 AC 123 ms
6,756 KB
testcase_27 AC 30 ms
4,624 KB
testcase_28 AC 31 ms
4,620 KB
testcase_29 AC 30 ms
4,612 KB
testcase_30 AC 31 ms
4,720 KB
testcase_31 AC 66 ms
5,644 KB
testcase_32 AC 118 ms
6,980 KB
testcase_33 AC 109 ms
6,616 KB
testcase_34 AC 110 ms
6,684 KB
testcase_35 AC 35 ms
5,016 KB
testcase_36 AC 81 ms
5,776 KB
testcase_37 AC 109 ms
6,660 KB
testcase_38 AC 98 ms
6,712 KB
testcase_39 AC 46 ms
5,240 KB
testcase_40 AC 50 ms
5,176 KB
testcase_41 AC 103 ms
6,620 KB
testcase_42 AC 108 ms
6,620 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