結果

問題 No.716 距離
ユーザー j0tdj0td
提出日時 2018-08-17 19:12:14
言語 JavaScript
(node v23.5.0)
結果
WA  
実行時間 -
コード長 620 bytes
コンパイル時間 83 ms
コンパイル使用メモリ 6,688 KB
実行使用メモリ 42,548 KB
最終ジャッジ日時 2024-10-13 00:39:16
合計ジャッジ時間 3,894 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
  })

  var minDistance = Infinity

  for (var i = 1; i < sorted.length; i ++) {
    Math.abs(sorted[i] - sorted[i - 1]) < minDistance ? minDistance = sorted[i] - sorted[i - 1] : false
  }

  console.log(minDistance)
  console.log(Math.abs(sorted[0] - sorted[sorted.length - 1]))
})
0