結果

問題 No.275 中央値を求めよ
コンテスト
ユーザー mondo
提出日時 2019-08-14 16:56:18
言語 JavaScript
(node v25.8.2)
コンパイル:
true
実行:
node _filename_ ONLINE_JUDGE
結果
AC  
実行時間 93 ms / 1,000 ms
コード長 345 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 128 ms
コンパイル使用メモリ 6,528 KB
実行使用メモリ 52,468 KB
最終ジャッジ日時 2026-04-30 07:15:59
合計ジャッジ時間 5,504 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 38
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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