結果

問題 No.406 鴨等間隔の法則
ユーザー koari
提出日時 2020-02-18 13:01:23
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 51 ms / 2,000 ms
コード長 546 bytes
コンパイル時間 1,510 ms
コンパイル使用メモリ 176,316 KB
実行使用メモリ 8,448 KB
最終ジャッジ日時 2024-07-07 12:47:40
合計ジャッジ時間 3,298 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;

int main(void){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> x(n);
  set<int> s;
  rep(i,n){
    cin >> x[i];
    s.insert(x[i]);
  }
  if(s.size()==1){
    cout << "NO" << endl;
    return 0;
  }
  sort(x.begin(),x.end());
  int kyori = x[1] - x[0];
  for(int i=2;i<n;i++){
    if(kyori!=x[i]-x[i-1]){
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
} 
0