結果

問題 No.406 鴨等間隔の法則
ユーザー btk
提出日時 2016-08-03 15:33:21
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 19 ms / 2,000 ms
コード長 404 bytes
コンパイル時間 1,618 ms
コンパイル使用メモリ 171,268 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-07 11:15:45
合計ジャッジ時間 2,685 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>

using namespace std;
struct I{I(){ios::sync_with_stdio(false);cin.tie(0);}}init;

int main(){
    int N;cin>>N;
    vector<int> x(N);
    for(auto &it:x)cin>>it;
    sort(x.begin(),x.end());
    int top=1,bottom=1e9;
    for(int i=1;i<N;i++)top=max(top,x[i]-x[i-1]),bottom=min(bottom,x[i]-x[i-1]);
    if(bottom==top)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}
0