結果
| 問題 |
No.275 中央値を求めよ
|
| コンテスト | |
| ユーザー |
💕💖💞
|
| 提出日時 | 2016-09-11 18:15:35 |
| 言語 | Go (1.23.4) |
| 結果 |
AC
|
| 実行時間 | 10 ms / 1,000 ms |
| コード長 | 672 bytes |
| コンパイル時間 | 16,961 ms |
| コンパイル使用メモリ | 233,120 KB |
| 実行使用メモリ | 11,776 KB |
| 最終ジャッジ日時 | 2024-06-25 00:01:54 |
| 合計ジャッジ時間 | 16,831 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 38 |
ソースコード
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)
}
💕💖💞