結果
| 問題 |
No.178 美しいWhitespace (1)
|
| コンテスト | |
| ユーザー |
gogotea
|
| 提出日時 | 2015-04-06 00:57:54 |
| 言語 | Go1.4 (1.4.2) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 763 bytes |
| コンパイル時間 | 562 ms |
| コンパイル使用メモリ | 34,048 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-11-25 00:11:20 |
| 合計ジャッジ時間 | 1,366 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 21 |
ソースコード
package main
import (
"bufio"
"fmt"
"os"
"strconv"
)
func main() {
lines, max := input()
result := count(lines, max)
fmt.Println(result)
}
func input() ([]int, int) {
N := nextInt()
lines := make([]int, N)
max := 0
for i := 0; i < N; i++ {
a := nextInt()
b := nextInt()
lines[i] = a + b*4
if lines[i] > max {
max = lines[i]
}
}
return lines, max
}
func count(lines []int, max int) int {
result := 0
for _, w := range lines {
diff := max - w
if diff%2 != 0 {
return -1
}
result += diff / 2
}
return result
}
var sc = bufio.NewScanner(os.Stdin)
func next() string {
sc.Split(bufio.ScanWords)
sc.Scan()
return sc.Text()
}
func nextInt() int {
i, e := strconv.Atoi(next())
if e != nil {
panic(e)
}
return i
}
gogotea