結果

問題 No.275 中央値を求めよ
コンテスト
ユーザー nobigomu
提出日時 2018-04-22 13:41:31
言語 Lua
(LuaJit 2.1.1774638290)
コンパイル:
luajit -b _filename_ a.out
実行:
luajit _filename_
結果
WA  
実行時間 -
コード長 409 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 78 ms
コンパイル使用メモリ 6,144 KB
実行使用メモリ 6,144 KB
最終ジャッジ日時 2026-03-14 13:16:43
合計ジャッジ時間 1,271 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 4 WA * 34
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

print((function (f, g, n, s)
	return f(g(n,s))
end)(function (n)
	return (n==math.floor(n) and "%.0f" or "%.1f"):format(n)
end, function (n, s)
	local a,rs={},bit.rshift
	for e in s:gmatch("%d+") do table.insert(a,tonumber(e)) end
	table.sort(a)
	if n==1 then return a[1] end
	if n%2~=0 then return a[rs(n,1)+1] end
	return (a[rs(n,1)]+a[rs(n,1)+1])/2
end, tonumber(io.stdin:read("*l")), io.stdin:read("*l")))
0