結果

問題 No.178 美しいWhitespace (1)
コンテスト
ユーザー vorg101
提出日時 2016-07-30 13:05:57
言語 Go
(1.27.0 + ACL)
コンパイル:
/usr/bin/go_c
実行:
./Main
結果
AC  
実行時間 9 ms / 2,000 ms
+ 15µs
コード長 492 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 14,818 ms
コンパイル使用メモリ 268,080 KB
実行使用メモリ 9,936 KB
最終ジャッジ日時 2026-09-19 20:18:33
合計ジャッジ時間 11,592 ms
ジャッジサーバーID
(参考情報)
judge5_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

package main

import (
    "fmt"
    "math"
)

func main() {
    var n, ans int
    fmt.Scan(&n)
    max := -1
    for i := 0; i < n; i++ {
        var a, b int
        fmt.Scan(&a, &b)
        w := a + 4 * b

        if int(math.Abs(float64(max - w))) % 2 != 0 && max != -1{
            ans = -1
            break
        }

        if w > max {
            ans += (w - max) / 2 * i
            max = w
        } else {
            ans += (max - w) / 2
        }
    }
    fmt.Println(ans)
}
0