結果

問題 No.1884 Sequence
ユーザー osk_x64osk_x64
提出日時 2022-03-25 23:28:38
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 918 bytes
コンパイル時間 2,162 ms
コンパイル使用メモリ 202,248 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-22 08:26:57
合計ジャッジ時間 6,745 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 142 ms
5,376 KB
testcase_11 AC 141 ms
5,376 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 31 ms
5,376 KB
testcase_15 AC 89 ms
5,376 KB
testcase_16 AC 138 ms
5,376 KB
testcase_17 AC 63 ms
5,376 KB
testcase_18 AC 88 ms
5,376 KB
testcase_19 AC 70 ms
5,376 KB
testcase_20 AC 76 ms
5,376 KB
testcase_21 AC 60 ms
5,376 KB
testcase_22 AC 82 ms
5,376 KB
testcase_23 AC 139 ms
5,376 KB
testcase_24 AC 138 ms
5,376 KB
testcase_25 AC 131 ms
5,376 KB
testcase_26 AC 137 ms
5,376 KB
testcase_27 AC 36 ms
5,376 KB
testcase_28 AC 36 ms
5,376 KB
testcase_29 AC 36 ms
5,376 KB
testcase_30 AC 36 ms
5,376 KB
testcase_31 AC 74 ms
5,376 KB
testcase_32 AC 134 ms
5,376 KB
testcase_33 AC 126 ms
5,376 KB
testcase_34 AC 126 ms
5,376 KB
testcase_35 AC 43 ms
5,376 KB
testcase_36 AC 96 ms
5,376 KB
testcase_37 AC 126 ms
5,376 KB
testcase_38 AC 113 ms
5,376 KB
testcase_39 AC 55 ms
5,376 KB
testcase_40 AC 60 ms
5,376 KB
testcase_41 AC 113 ms
5,376 KB
testcase_42 AC 114 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
using ll = long long;

int main() {
  int N;
  cin >> N;
  vector<ll> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  sort(ALL(A));
  
  const ll INF = 1LL << 60;

  ll t = INF, mx = -INF;
  int z = 0;
  for (int i = 0; i < N-1; i++) {
    if(A[i] == 0) z++;
    else {
      t = min(t, A[i+1] - A[i]);
      mx = max(mx, A[i+1] - A[i]);
    }
  }

  if(t == INF) {
    cout << "Yes" << endl;
    return 0;
  }

  if(t == 0) {
    if(mx != 0) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
  }

  bool ans = true;
  for (int i = 0; i < N-1; i++) {
    if(A[i] == 0) continue;
    ll x = A[i+1] - A[i];
    if(x == t) continue;
    if(x % t) ans = false;
    z -= x / t -1;
    if(z < 0) ans = false;
  }
  cout << (ans ? "Yes" : "No") << endl;
  return 0;
}
0