結果
問題 |
No.275 中央値を求めよ
|
ユーザー |
|
提出日時 | 2019-08-04 23:17:47 |
言語 | Go (1.23.4) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 461 bytes |
コンパイル時間 | 13,822 ms |
コンパイル使用メモリ | 220,948 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-17 22:19:09 |
合計ジャッジ時間 | 13,111 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 38 |
ソースコード
package main import ( "bufio" "fmt" "os" "sort" "strconv" ) func main() { sc := bufio.NewScanner(os.Stdin) sc.Split(bufio.ScanWords) sc.Scan() N, _ := strconv.Atoi(sc.Text()) nums := make([]int, N) var t int for i := range nums { sc.Scan() t, _ = strconv.Atoi(sc.Text()) nums[i] = t } sort.Ints(nums) l := len(nums) if l%2 == 0 { fmt.Println((float64(nums[l/2-1]) + float64(nums[l/2])) / 2) } else { fmt.Println(nums[(l-1)/2]) } }