結果

問題 No.135 とりあえず1次元の問題
ユーザー kiridaruma
提出日時 2016-05-16 14:03:19
言語 D
(dmd 2.109.1)
結果
AC  
実行時間 27 ms / 5,000 ms
コード長 485 bytes
コンパイル時間 862 ms
コンパイル使用メモリ 104,960 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-12 03:31:49
合計ジャッジ時間 1,969 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.stdio, std.string, std.conv;
import std.algorithm, std.array;
import core.stdc.stdlib;

void main(){
    auto s = readln.strip.to!int;
    int[] arr = readln.strip.split.map!(to!int).array;
    if(s == 1){0.writeln;exit(-1);}
    arr.sort;
    int ans = int.max, before = arr[0];
    foreach(i, x; arr){
        if(before == x) continue;
        if(ans > x - before){
            ans = x - before;
        }
        before = x;
    }
    writeln(ans != int.max ? ans : 0);
}
0