結果

問題 No.275 中央値を求めよ
ユーザー 💕💖💞💕💖💞
提出日時 2016-09-11 18:15:35
言語 Go
(1.22.1)
結果
AC  
実行時間 6 ms / 1,000 ms
コード長 672 bytes
コンパイル時間 13,441 ms
コンパイル使用メモリ 213,900 KB
実行使用メモリ 14,388 KB
最終ジャッジ日時 2023-09-07 05:35:25
合計ジャッジ時間 15,316 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
14,384 KB
testcase_01 AC 5 ms
14,384 KB
testcase_02 AC 5 ms
14,384 KB
testcase_03 AC 5 ms
14,388 KB
testcase_04 AC 5 ms
14,384 KB
testcase_05 AC 5 ms
14,384 KB
testcase_06 AC 5 ms
14,384 KB
testcase_07 AC 5 ms
14,388 KB
testcase_08 AC 5 ms
14,384 KB
testcase_09 AC 5 ms
14,384 KB
testcase_10 AC 5 ms
14,384 KB
testcase_11 AC 5 ms
14,384 KB
testcase_12 AC 5 ms
14,384 KB
testcase_13 AC 5 ms
14,384 KB
testcase_14 AC 5 ms
14,384 KB
testcase_15 AC 5 ms
14,388 KB
testcase_16 AC 5 ms
14,388 KB
testcase_17 AC 5 ms
14,388 KB
testcase_18 AC 5 ms
14,384 KB
testcase_19 AC 5 ms
14,384 KB
testcase_20 AC 5 ms
14,384 KB
testcase_21 AC 6 ms
14,384 KB
testcase_22 AC 5 ms
14,384 KB
testcase_23 AC 5 ms
14,384 KB
testcase_24 AC 5 ms
14,384 KB
testcase_25 AC 5 ms
14,388 KB
testcase_26 AC 5 ms
14,388 KB
testcase_27 AC 5 ms
14,388 KB
testcase_28 AC 5 ms
14,384 KB
testcase_29 AC 5 ms
14,388 KB
testcase_30 AC 5 ms
14,388 KB
testcase_31 AC 6 ms
14,388 KB
testcase_32 AC 5 ms
14,388 KB
testcase_33 AC 6 ms
14,388 KB
testcase_34 AC 5 ms
14,384 KB
testcase_35 AC 5 ms
14,388 KB
testcase_36 AC 5 ms
14,384 KB
testcase_37 AC 5 ms
14,388 KB
testcase_38 AC 5 ms
14,384 KB
testcase_39 AC 6 ms
14,388 KB
testcase_40 AC 5 ms
14,388 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

import (
  "bufio"
  "fmt"
  "os"
  "strconv"
  "strings"
  _ "math"
  "sort"
)

func main() {
  srcs := []float64{}
  _ = gets()
  for _, x := range strings.Split(gets(), " ") {
    x2, _ := strconv.ParseFloat(x, 64)
    srcs = append(srcs, x2)
  }
  sort.Float64s(srcs)
  if len(srcs) % 2 == 0 {
    mid := len(srcs)/2
    fmt.Println( (srcs[mid-1] + srcs[mid])/2.0 )
  } else {
    mid := len(srcs)/2
    fmt.Println( srcs[mid] )
  }
}

var rdr = bufio.NewReaderSize(os.Stdin, 10000000)
func gets() string {
  buf := make([]byte, 0, 10000000)
  for {
    l, p, _ := rdr.ReadLine()
    buf = append(buf, l...)
    if !p { break }
  }
  return string(buf)
}
0