結果

問題 No.406 鴨等間隔の法則
ユーザー トミー
提出日時 2024-03-29 23:30:13
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 51 ms / 2,000 ms
コード長 535 bytes
コンパイル時間 2,046 ms
コンパイル使用メモリ 197,824 KB
最終ジャッジ日時 2025-02-20 15:38:40
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin >> n;
    vector<int> x(n);
    int distance;
    bool f = true;
    for (auto &i : x) {
        cin >> i;
    }
    sort(x.begin(), x.end());
    distance = x[1] - x[0];
    f=(distance!=0);
    for (int i = 2; i != x.size()&&f; i++) {
        if (distance != x[i] - x[i - 1]) {
            f = false;
            break;
        }
    }
    if (f) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    // system("pause");
}
0