結果

問題 No.275 中央値を求めよ
コンテスト
ユーザー Leonardone
提出日時 2016-04-03 01:24:15
言語 Lua
(LuaJit 2.1.1774638290)
コンパイル:
luajit -b _filename_ a.out
実行:
luajit _filename_
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 281 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 96 ms
コンパイル使用メモリ 7,844 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2026-03-11 03:52:20
合計ジャッジ時間 1,180 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 38
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

-- yukicoder My Practice
-- author: Leonardone @ NEETSDKASU

n = io.read()

t = {}
i = 1
for c in io.read():gmatch('%S+') do
	t[i] = tonumber(c)
	i = i + 1
end

table.sort(t)

if n % 2 == 0 then
	x = n / 2
	print((t[x] + t[x + 1]) / 2)
else
	x = math.ceil(n / 2)
	print(t[x])
end

0