結果

問題 No.406 鴨等間隔の法則
コンテスト
ユーザー shi-mo
提出日時 2016-08-31 21:52:48
言語 D
(dmd 2.112.0)
コンパイル:
dmd -fPIE -m64 -w -wi -O -release -inline -I/opt/dmd/src/druntime/import/ -I/opt/dmd/src/phobos -L-L/opt/dmd/linux/lib64/ -fPIC _filename_
実行:
./Main
結果
AC  
実行時間 38 ms / 2,000 ms
コード長 425 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,353 ms
コンパイル使用メモリ 123,052 KB
実行使用メモリ 8,920 KB
最終ジャッジ日時 2026-03-05 07:16:33
合計ジャッジ時間 3,036 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import std.stdio;
import std.conv;
import std.array;
import std.algorithm;

void main() {
    int n;
    readf("%s\n", &n);

    uint[] x = readln().split.map!(to!uint).array;
    sort(x);

    uint d = x[1] - x[0];
    if (0 == d) {
        writeln("NO");
        return;
    }

    foreach (i; 2..n) {
        if ((x[i] - x[i-1]) != d) {
            writeln("NO");
            return;
        }
    }
    writeln("YES");
}
0