結果

問題 No.406 鴨等間隔の法則
ユーザー megane_anko
提出日時 2021-03-16 11:36:16
言語 TypeScript
(5.7.2)
結果
AC  
実行時間 220 ms / 2,000 ms
コード長 597 bytes
コンパイル時間 8,027 ms
コンパイル使用メモリ 229,416 KB
実行使用メモリ 53,612 KB
最終ジャッジ日時 2024-12-31 16:34:47
合計ジャッジ時間 13,739 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

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