結果

問題 No.178 美しいWhitespace (1)
ユーザー tyochiaityochiai
提出日時 2015-07-18 00:49:55
言語 Go
(1.22.1)
結果
WA  
実行時間 -
コード長 592 bytes
コンパイル時間 12,280 ms
コンパイル使用メモリ 230,284 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-19 02:36:29
合計ジャッジ時間 11,690 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,248 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 18 ms
5,376 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 18 ms
5,376 KB
testcase_12 AC 18 ms
5,376 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 18 ms
5,376 KB
testcase_19 WA -
testcase_20 AC 18 ms
5,376 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 19 ms
5,376 KB
testcase_24 AC 21 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

import (
	"fmt"
	"math"
)

var (
	N int
	a []int
	b []int
)

func resolve() float64 {
	ret := float64(0)
	maxLen := float64(a[0]*1 + b[0]*4)
	rest := a[0] % 2
	for i := 0; i < N; i++ {
		tmp := float64(a[i]*1 + b[i]*4)
		if a[i]%2 != rest {
			return -1
		}
		if maxLen > tmp {
			ret += math.Abs(maxLen-tmp) / 2
			continue
		}
		ret += math.Abs(maxLen-tmp) / 2 * float64(i)
		maxLen = tmp
	}
	return ret
}

func main() {
	fmt.Scanf("%d\n", &N)
	a = make([]int, N)
	b = make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scanf("%d %d\n", &a[i], &b[i])
	}
	fmt.Println(resolve())
}
0