結果

問題 No.406 鴨等間隔の法則
ユーザー face4
提出日時 2018-04-21 19:22:31
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 83 ms / 2,000 ms
コード長 559 bytes
コンパイル時間 793 ms
コンパイル使用メモリ 77,312 KB
実行使用メモリ 8,704 KB
最終ジャッジ日時 2024-07-07 12:23:04
合計ジャッジ時間 2,471 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<set>
#include<algorithm>
using namespace std;

int main(){
    int n;
    set<int> x;
    cin >> n;
    int A[n];
    for(int i = 0; i < n; i++){
        cin >> A[i];
        if(x.find(A[i]) != x.end()){
            cout << "NO" << endl;
            return 0;
        }
        x.insert(A[i]);
    }

    sort(A, A + n);
    int diff = A[1]-A[0];
    for(int i = 1; i < n-1; i++){
        if(A[i+1] - A[i] != diff){
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;
    return 0;
}
0