結果

問題 No.716 距離
ユーザー j0tdj0td
提出日時 2018-08-17 19:00:08
言語 JavaScript
(node v23.5.0)
結果
WA  
実行時間 -
コード長 584 bytes
コンパイル時間 48 ms
コンパイル使用メモリ 6,696 KB
実行使用メモリ 42,564 KB
最終ジャッジ日時 2024-10-13 00:39:08
合計ジャッジ時間 4,162 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 3 WA * 37
権限があれば一括ダウンロードができます

ソースコード

diff #

let lines = []

const reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
})

reader.on('line', (line) => {
  lines.push(line)
})

reader.on('close', () => {
  let points = lines[1].split(' ')
  let sorted = points.sort((a, b) => {
    if (a < b) return -1
    if (a > b) return 1
    return 0
  })

  let distances = []

  for (var i = 1; i < sorted.length; i ++) {
    distances.push(Math.abs(sorted[i] - sorted[i - 1]))
  }

  console.log(Math.min.apply(null, distances))
  console.log(Math.abs(sorted[0] - sorted[sorted.length - 1]))
})
0