結果

問題 No.135 とりあえず1次元の問題
ユーザー ontama_12ontama_12
提出日時 2016-09-27 12:55:32
言語 JavaScript
(node v21.7.1)
結果
RE  
実行時間 -
コード長 1,320 bytes
コンパイル時間 78 ms
コンパイル使用メモリ 6,944 KB
実行使用メモリ 48,212 KB
最終ジャッジ日時 2024-04-21 01:30:20
合計ジャッジ時間 2,890 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 AC 74 ms
42,104 KB
testcase_02 AC 73 ms
39,936 KB
testcase_03 AC 74 ms
39,936 KB
testcase_04 AC 75 ms
39,936 KB
testcase_05 AC 73 ms
40,320 KB
testcase_06 AC 78 ms
42,060 KB
testcase_07 AC 74 ms
40,064 KB
testcase_08 AC 75 ms
39,936 KB
testcase_09 AC 74 ms
40,064 KB
testcase_10 AC 74 ms
42,068 KB
testcase_11 AC 75 ms
42,072 KB
testcase_12 AC 75 ms
42,192 KB
testcase_13 AC 74 ms
42,196 KB
testcase_14 AC 78 ms
43,520 KB
testcase_15 AC 76 ms
42,200 KB
testcase_16 AC 76 ms
45,652 KB
testcase_17 AC 77 ms
45,524 KB
testcase_18 AC 74 ms
39,936 KB
testcase_19 AC 77 ms
43,648 KB
testcase_20 AC 74 ms
40,448 KB
testcase_21 RE -
testcase_22 RE -
evil01.txt RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

   /////////////////////////////No.135 とりあえず1次元の問題
    //入力文字読み取り
    process.stdin.resume();
    process.stdin.setEncoding('utf8');
    process.stdin.on('data', function (chunk) {

        //すべて受け取り改行で区切って格納
        var inputall = chunk.split("\n");

        //座標点の合計値
        var coordinateall =Number( inputall[0]);

        //座標点をひとつずつを配列に格納
        var coordinate = inputall[1].split(" ").map(Number);
        
        //座標点をソート
        coordinate.sort(
    function (a, b) {
        if (a < b) return -1;
        if (a > b) return 1;
        return 0;
    });
      //座標間の最小値をcountに代入し、更新していく。初期値を座標間の最大値にしておく
        var count = 1000000
        for (var i = 0; i < coordinateall-1; i++) {
            var coordinate_difference = coordinate[i + 1] - coordinate[i]
            if (coordinate_difference < count && coordinate_difference != 0) { 
                count = coordinate_difference;
            }
        }

    //座標間の最小値を出力、座標間が0のみであれば0を出力
        if(count ==1000000){
            console.log(0)
        }else{
            console.log(count)
        }
    });
0