結果

問題 No.99 ジャンピング駒
ユーザー t_muranot_murano
提出日時 2016-06-11 16:25:53
言語 Go
(1.21.3)
結果
AC  
実行時間 12 ms / 5,000 ms
コード長 492 bytes
コンパイル時間 11,505 ms
コンパイル使用メモリ 213,688 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-01 13:29:26
合計ジャッジ時間 11,789 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
4,384 KB
testcase_01 AC 11 ms
4,380 KB
testcase_02 AC 12 ms
4,376 KB
testcase_03 AC 12 ms
4,380 KB
testcase_04 AC 11 ms
4,380 KB
testcase_05 AC 12 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func absInt(num int) int {
	if num < 0 {
		return -num
	}
	return num
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	n := nextInt(sc)
	count := 0

	for i := 0; i < n; i++ {
		if nextInt(sc)%2 == 0 {
			count += 1
		} else {
			count -= 1
		}
	}

	fmt.Println(absInt(count))
}
0