結果

問題 No.1884 Sequence
ユーザー bonKotsubonKotsu
提出日時 2022-07-28 15:29:46
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 267 ms / 2,000 ms
コード長 1,097 bytes
コンパイル時間 4,801 ms
コンパイル使用メモリ 268,060 KB
実行使用メモリ 14,256 KB
最終ジャッジ日時 2023-09-25 07:42:58
合計ジャッジ時間 12,225 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 254 ms
14,148 KB
testcase_11 AC 254 ms
14,156 KB
testcase_12 AC 24 ms
4,376 KB
testcase_13 AC 26 ms
4,380 KB
testcase_14 AC 25 ms
4,376 KB
testcase_15 AC 120 ms
8,672 KB
testcase_16 AC 252 ms
13,988 KB
testcase_17 AC 70 ms
6,248 KB
testcase_18 AC 112 ms
9,540 KB
testcase_19 AC 87 ms
7,920 KB
testcase_20 AC 101 ms
7,316 KB
testcase_21 AC 67 ms
5,540 KB
testcase_22 AC 109 ms
7,928 KB
testcase_23 AC 252 ms
14,036 KB
testcase_24 AC 267 ms
13,988 KB
testcase_25 AC 251 ms
14,256 KB
testcase_26 AC 251 ms
13,952 KB
testcase_27 AC 29 ms
4,380 KB
testcase_28 AC 29 ms
4,376 KB
testcase_29 AC 29 ms
4,380 KB
testcase_30 AC 29 ms
4,380 KB
testcase_31 AC 99 ms
7,472 KB
testcase_32 AC 233 ms
13,460 KB
testcase_33 AC 113 ms
5,076 KB
testcase_34 AC 113 ms
5,228 KB
testcase_35 AC 34 ms
4,380 KB
testcase_36 AC 84 ms
4,376 KB
testcase_37 AC 116 ms
5,128 KB
testcase_38 AC 104 ms
5,096 KB
testcase_39 AC 47 ms
4,376 KB
testcase_40 AC 51 ms
4,380 KB
testcase_41 AC 193 ms
11,392 KB
testcase_42 AC 188 ms
11,396 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;

#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
#define LP pair<ll, ll>
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define all(s) s.begin(), s.end()
#define rall(s) s.rbegin(), s.rend()
template<class T>
void chmax(T& a, T b) { a = max(a, b); };
template<class T>
void chmin(T& a, T b) { a = min(a, b); };

int main() {
  int n;
  cin >> n;
  vector<ll> a;
  set<ll> s;
  ll cnt1 = 0;
  rep(i,n) {
    ll x;
    cin >> x;
    if (x == 0) cnt1++;
    else {
      a.pb(x);
      s.insert(x);
    }
  }
  if (a.size() <= 1 || s.size() <= 1) {
    cout << "Yes" << endl;
    return 0;
  }


  sort(all(a));
  ll g = a[1]-a[0];
  rep(i,a.size()-1) {
    if (a[i+1]-a[i] == 0) {
      cout << "No" << endl;
      return 0;
    } 
    g = gcd(g, a[i+1]-a[i]);
  }
  ll cnt2 = 0;
  rep(i,a.size()-1) {
    cnt2 += (a[i+1]-a[i])/g-1;
  }
  if (cnt1 >= cnt2) cout << "Yes" << endl;
  else cout << "No" << endl;

  
  return 0;
}
0