結果

問題 No.406 鴨等間隔の法則
ユーザー itezpace
提出日時 2016-08-05 22:54:52
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 45 ms / 2,000 ms
コード長 447 bytes
コンパイル時間 1,487 ms
コンパイル使用メモリ 162,644 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-07 11:25:21
合計ジャッジ時間 3,009 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){
  int n,x;
  cin>>n;
  vector<int> v;
  for(int i=0; i<n; ++i){
    cin>>x;
    v.push_back(x);
  }
  sort(v.begin(),v.end(),greater<int>());
  int d,e;
  d=v[0]-v[1];
  if(d==0){
    cout<<"NO"<<endl;
    return 0;
  }
  for(int i=1; i<n-1; ++i){
    e=v[i]-v[i+1];
    if(d!=e){
      cout<<"NO"<<endl;
      return 0;
    }
  }
  cout<<"YES"<<endl;
  return 0;
}
0