結果

問題 No.406 鴨等間隔の法則
ユーザー megane_ankomegane_anko
提出日時 2021-03-16 11:36:16
言語 TypeScript
(5.4.3)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 597 bytes
コンパイル時間 3,835 ms
コンパイル使用メモリ 145,712 KB
最終ジャッジ日時 2024-04-27 03:44:08
合計ジャッジ時間 4,583 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
main.ts(1,21): error TS2307: Cannot find module 'fs' or its corresponding type declarations.

ソースコード

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