結果

問題 No.406 鴨等間隔の法則
ユーザー r2en_
提出日時 2017-07-05 00:49:56
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 44 ms / 2,000 ms
コード長 451 bytes
コンパイル時間 595 ms
コンパイル使用メモリ 75,328 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-07 12:11:01
合計ジャッジ時間 2,362 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    for(int i=0; i<n; ++i) {
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    bool ok = true;
    int d = v[1]-v[0];
    for(int i=0; i<n-1; ++i) {
        ok &= d == v[i+1]-v[i] && v[i] != v[i+1];
    }
    if(ok) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}
0