結果

問題 No.406 鴨等間隔の法則
ユーザー aaaaaaiu
提出日時 2019-07-27 22:55:29
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 53 ms / 2,000 ms
コード長 411 bytes
コンパイル時間 1,935 ms
コンパイル使用メモリ 196,304 KB
最終ジャッジ日時 2025-01-07 09:40:08
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a,a+n);
    for (int i = 2; i < n; i++) {
        int d = a[i]-a[i-1];
        int prevd = a[i-1]-a[i-2];
        if (d != prevd || d == 0) {
            puts("NO");
            return 0;
        }
    }
    puts("YES");
    return 0;
}
0