結果

問題 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  
実行時間 22 ms / 2,000 ms
+ 704µs
コード長 425 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 825 ms
コンパイル使用メモリ 120,576 KB
実行使用メモリ 6,168 KB
最終ジャッジ日時 2026-07-25 22:57:48
合計ジャッジ時間 3,209 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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