結果

問題 No.406 鴨等間隔の法則
コンテスト
ユーザー himueu
提出日時 2026-10-18 20:25:48
言語 C++23(gcc16)
(gcc 16.2.0 + boost 1.92.0 + ACL)
コンパイル:
g++-16 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 33 ms / 2,000 ms
+ 591µs
コード長 499 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 3,125 ms
コンパイル使用メモリ 182,376 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-10-18 20:25:55
合計ジャッジ時間 5,990 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge6_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <algorithm>
#include <iostream>
#include <vector>

int main() {
    using namespace std;
    int n;
    cin >> n;
    vector<int> x(n);
    for (auto &e : x) { cin >> e; }
    sort(x.begin(), x.end());
    if (x[0] == x[1]) {
        cout << "NO\n";
    } else {
        string ans = "YES\n";
        for (int i = 0; i < n - 1; i++) {
            if (x[i + 1] - x[i] != x[1] - x[0]) {
                ans = "NO\n";
                break;
            }
        }
        cout << ans;
    }
}
0