結果

問題 No.135 とりあえず1次元の問題
ユーザー destagia
提出日時 2021-02-28 02:14:10
言語 TypeScript
(5.7.2)
結果
WA  
実行時間 -
コード長 477 bytes
コンパイル時間 8,365 ms
コンパイル使用メモリ 229,484 KB
実行使用メモリ 49,816 KB
最終ジャッジ日時 2024-12-31 16:30:31
合計ジャッジ時間 11,295 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 1
other AC * 6 WA * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

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

const [NStr, xArrStr] = input.split('\n');
const N = parseInt(NStr);
const xs = xArrStr.split(' ').map(s => parseInt(s));

if (N === 1) {
  console.log(0);
} else {
  let min = 1000000;
  for (let i = 1; i < xs.length; i++) {
    min = Math.min(min, Math.abs(xs[i - 1] - xs[i]));
    if (i < xs.length - 1) {
      min = Math.min(min, Math.abs(xs[i] - xs[i + 1]));
    }
  }

  console.log(min);
}
0