結果

問題 No.406 鴨等間隔の法則
ユーザー kyo1
提出日時 2020-04-17 00:35:12
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 24 ms / 2,000 ms
コード長 472 bytes
コンパイル時間 1,784 ms
コンパイル使用メモリ 175,604 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-03 05:11:58
合計ジャッジ時間 2,792 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<int> X(N);
  for (int i = 0; i < N; i++) {
    cin >> X[i];
  }
  sort(X.begin(), X.end());
  set<int> st;
  for (int i = 0; i < N - 1; i++) {
    if (X[i + 1] == X[i]) st.insert(-1);
    st.insert(abs(X[i + 1] - X[i]));
  }
  if ((int)st.size() == 1) {
    cout << "YES" << '\n';
  } else {
    cout << "NO" << '\n';
  }
  return 0;
}
0