結果
問題 |
No.275 中央値を求めよ
|
ユーザー |
|
提出日時 | 2017-06-19 19:57:19 |
言語 | D (dmd 2.109.1) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 546 bytes |
コンパイル時間 | 2,593 ms |
コンパイル使用メモリ | 156,368 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-12 20:17:13 |
合計ジャッジ時間 | 3,727 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 38 |
ソースコード
import std.stdio, std.string, std.conv, std.algorithm; import std.range, std.array, std.math, std.typecons; int n; int[] a; void main() { scan(n); a = readln.split.to!(int[]); a.sort(); if (n & 1) { writeln(a[n/2]); } else { double ans = (a[n/2] + a[n/2 - 1]) / 2.0; writefln("%.1f", ans); } } void scan(T...)(ref T args) { auto line = readln.split; foreach (ref arg ; args) { arg = line.front.to!(typeof(arg)); line.popFront(); } assert(line.empty); }