結果
| 問題 |
No.609 Noelちゃんと星々
|
| コンテスト | |
| ユーザー |
tsuchinaga
|
| 提出日時 | 2019-03-15 09:19:00 |
| 言語 | Go (1.23.4) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 564 bytes |
| コンパイル時間 | 14,008 ms |
| コンパイル使用メモリ | 225,792 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-06-28 14:29:33 |
| 合計ジャッジ時間 | 15,059 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | WA * 25 |
ソースコード
package main
import (
"bufio"
"fmt"
"math"
"os"
"strconv"
)
func main() {
var n int
_, _ = fmt.Scan(&n)
bi := bufio.NewScanner(os.Stdin)
bi.Split(bufio.ScanWords)
sum := 0
nums := make([]int, n)
for i := range nums {
bi.Scan()
a, _ := strconv.Atoi(bi.Text())
sum += a
nums[i] = a
}
c, f := int(math.Ceil(float64(sum)/float64(n))), int(math.Floor(math.Ceil(float64(sum)/float64(n))))
var cd, fd float64
for _, a := range nums {
cd += math.Abs(float64(c - a))
fd += math.Abs(float64(f - a))
}
fmt.Println(int(math.Min(cd, fd)))
}
tsuchinaga