結果

問題 No.406 鴨等間隔の法則
ユーザー legosuke
提出日時 2017-10-08 17:41:22
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 94 ms / 2,000 ms
コード長 403 bytes
コンパイル時間 1,487 ms
コンパイル使用メモリ 167,016 KB
実行使用メモリ 8,224 KB
最終ジャッジ日時 2024-07-07 12:12:53
合計ジャッジ時間 4,098 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

int main(void) {
  int n;
  cin >> n;

  vector<int> x(n);
  set<int> st;
  for (int i = 0; i < n; i++) {
    cin >> x[i];
    st.insert(x[i]);
  }
  sort(x.begin(), x.end());

  bool yes = (st.size() == n);
  int d = x[1] - x[0];
  for (int i = 2; i < n; i++) {
    yes &= x[i] - x[i - 1] == d;
  }

  cout << (yes ? "YES" : "NO") << endl;

  return 0;
}
0