結果

問題 No.406 鴨等間隔の法則
ユーザー megane_ankomegane_anko
提出日時 2021-03-16 11:36:16
言語 TypeScript
(5.4.3)
結果
AC  
実行時間 221 ms / 2,000 ms
コード長 597 bytes
コンパイル時間 9,090 ms
コンパイル使用メモリ 254,372 KB
実行使用メモリ 54,864 KB
最終ジャッジ日時 2023-08-07 17:21:42
合計ジャッジ時間 14,897 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 134 ms
48,748 KB
testcase_01 AC 73 ms
42,352 KB
testcase_02 AC 73 ms
42,172 KB
testcase_03 AC 73 ms
42,380 KB
testcase_04 AC 198 ms
51,488 KB
testcase_05 AC 125 ms
48,272 KB
testcase_06 AC 127 ms
48,648 KB
testcase_07 AC 131 ms
48,704 KB
testcase_08 AC 197 ms
51,472 KB
testcase_09 AC 219 ms
54,640 KB
testcase_10 AC 133 ms
48,936 KB
testcase_11 AC 179 ms
50,536 KB
testcase_12 AC 145 ms
49,124 KB
testcase_13 AC 141 ms
49,192 KB
testcase_14 AC 190 ms
50,984 KB
testcase_15 AC 77 ms
42,540 KB
testcase_16 AC 84 ms
43,476 KB
testcase_17 AC 79 ms
43,504 KB
testcase_18 AC 79 ms
42,832 KB
testcase_19 AC 90 ms
44,284 KB
testcase_20 AC 96 ms
45,992 KB
testcase_21 AC 93 ms
45,640 KB
testcase_22 AC 111 ms
49,116 KB
testcase_23 AC 149 ms
49,308 KB
testcase_24 AC 175 ms
50,084 KB
testcase_25 AC 221 ms
54,864 KB
testcase_26 AC 220 ms
54,768 KB
testcase_27 AC 131 ms
52,752 KB
testcase_28 AC 141 ms
54,652 KB
testcase_29 AC 221 ms
54,564 KB
testcase_30 AC 219 ms
54,476 KB
testcase_31 AC 215 ms
54,308 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import * as fs from 'fs';
const input = fs.readFileSync('/dev/stdin', 'utf8');

const nlarray = input.split('\n');
const N = parseInt(nlarray[0]);
const xarray = nlarray[1].split(' ');
let n_xarray = xarray.map(Number);

n_xarray.sort(
    function(a, b) {
        if (a < b) return -1;
        if (a > b) return 1;
        return 0;
    }
);

let result = 'YES';
for (let i = 0;i < N - 2; i++) {
    if (n_xarray[i + 2] - n_xarray[i + 1] === n_xarray[i + 1] - n_xarray[i] && n_xarray[i + 1] - n_xarray[i] !== 0) {
        continue;
    } else {
        result = 'NO';
    }
}
console.log(result);
0