結果

問題 No.1884 Sequence
ユーザー bonKotsubonKotsu
提出日時 2022-07-28 15:27:59
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,097 bytes
コンパイル時間 6,191 ms
コンパイル使用メモリ 267,616 KB
実行使用メモリ 14,176 KB
最終ジャッジ日時 2023-09-25 07:40:04
合計ジャッジ時間 15,050 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,352 KB
testcase_01 AC 1 ms
4,352 KB
testcase_02 AC 2 ms
4,352 KB
testcase_03 RE -
testcase_04 AC 1 ms
4,352 KB
testcase_05 AC 2 ms
4,356 KB
testcase_06 AC 1 ms
4,352 KB
testcase_07 AC 1 ms
4,356 KB
testcase_08 AC 2 ms
4,356 KB
testcase_09 AC 2 ms
4,356 KB
testcase_10 AC 273 ms
14,008 KB
testcase_11 AC 268 ms
14,028 KB
testcase_12 AC 23 ms
4,352 KB
testcase_13 AC 26 ms
4,356 KB
testcase_14 AC 25 ms
4,352 KB
testcase_15 AC 130 ms
8,748 KB
testcase_16 AC 269 ms
14,108 KB
testcase_17 AC 70 ms
6,268 KB
testcase_18 AC 111 ms
9,344 KB
testcase_19 AC 86 ms
7,976 KB
testcase_20 AC 103 ms
7,308 KB
testcase_21 AC 71 ms
5,692 KB
testcase_22 AC 118 ms
7,772 KB
testcase_23 AC 274 ms
14,160 KB
testcase_24 AC 265 ms
14,176 KB
testcase_25 AC 258 ms
14,136 KB
testcase_26 AC 266 ms
14,100 KB
testcase_27 RE -
testcase_28 AC 29 ms
4,356 KB
testcase_29 AC 29 ms
4,356 KB
testcase_30 AC 29 ms
4,352 KB
testcase_31 AC 104 ms
7,536 KB
testcase_32 AC 251 ms
13,636 KB
testcase_33 AC 113 ms
5,432 KB
testcase_34 AC 113 ms
5,112 KB
testcase_35 AC 34 ms
4,356 KB
testcase_36 AC 83 ms
4,356 KB
testcase_37 AC 115 ms
5,252 KB
testcase_38 AC 105 ms
5,436 KB
testcase_39 AC 47 ms
4,356 KB
testcase_40 AC 50 ms
4,356 KB
testcase_41 AC 206 ms
11,536 KB
testcase_42 AC 198 ms
11,556 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