結果

問題 No.275 中央値を求めよ
ユーザー mondo
提出日時 2019-08-14 16:56:18
言語 JavaScript
(node v23.5.0)
結果
AC  
実行時間 66 ms / 1,000 ms
コード長 345 bytes
コンパイル時間 300 ms
コンパイル使用メモリ 6,820 KB
実行使用メモリ 44,660 KB
最終ジャッジ日時 2024-10-13 01:21:32
合計ジャッジ時間 3,850 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 38
権限があれば一括ダウンロードができます

ソースコード

diff #

const main = require('fs').readFileSync('/dev/stdin','utf8').split('\n');
const count = main[0];
const array = main[1].trim().split(' ').map(Number);
array.sort((a, b) => a - b);
let a = count / 2;
let b = a - 1;
if (count % 2 === 0) {
    console.log((array[a] + array[b]) / 2);
} else {
    let c = Math.floor(a);
    console.log(array[c]);
}
0