結果

問題 No.135 とりあえず1次元の問題
ユーザー ontama_12ontama_12
提出日時 2016-09-27 14:07:22
言語 JavaScript
(node v21.7.1)
結果
AC  
実行時間 222 ms / 5,000 ms
コード長 1,295 bytes
コンパイル時間 226 ms
コンパイル使用メモリ 7,068 KB
実行使用メモリ 53,288 KB
最終ジャッジ日時 2024-04-21 01:30:40
合計ジャッジ時間 2,997 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 222 ms
52,896 KB
testcase_01 AC 66 ms
39,296 KB
testcase_02 AC 64 ms
39,424 KB
testcase_03 AC 66 ms
39,552 KB
testcase_04 AC 65 ms
39,552 KB
testcase_05 AC 64 ms
39,552 KB
testcase_06 AC 65 ms
39,424 KB
testcase_07 AC 66 ms
39,424 KB
testcase_08 AC 66 ms
39,424 KB
testcase_09 AC 66 ms
39,296 KB
testcase_10 AC 65 ms
39,168 KB
testcase_11 AC 64 ms
39,168 KB
testcase_12 AC 65 ms
39,296 KB
testcase_13 AC 67 ms
39,296 KB
testcase_14 AC 67 ms
42,752 KB
testcase_15 AC 65 ms
39,296 KB
testcase_16 AC 67 ms
42,752 KB
testcase_17 AC 67 ms
42,624 KB
testcase_18 AC 64 ms
39,424 KB
testcase_19 AC 68 ms
42,496 KB
testcase_20 AC 66 ms
39,296 KB
testcase_21 AC 120 ms
50,420 KB
testcase_22 AC 214 ms
53,288 KB
evil01.txt AC 170 ms
53,288 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

      /////////////////////////////No.135 とりあえず1次元の問題
        //入力文字読み取り
        var x = require('fs').readFileSync('/dev/stdin', 'utf8');

        //すべて受け取り改行で区切って格納
        var inputall =  x.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に代入し、更新していく。初期値を座標間の最大値の+1にしておく
        var count = 1000001
        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 ==1000001){
            console.log(0)
        }else{
            console.log(count)
        }
0