結果

問題 No.99 ジャンピング駒
ユーザー t_muranot_murano
提出日時 2016-06-11 16:22:13
言語 Go
(1.22.1)
結果
RE  
実行時間 -
コード長 701 bytes
コンパイル時間 11,709 ms
コンパイル使用メモリ 214,116 KB
実行使用メモリ 8,088 KB
最終ジャッジ日時 2023-08-01 13:30:40
合計ジャッジ時間 19,901 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
権限があれば一括ダウンロードができます

ソースコード

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 scanIntN(n int) []int {
	var r int
	result := make([]int, n)
	for i := 0; i < n; i++ {
		if _, e := fmt.Scan(&r); e != nil {
			panic(e)
		} else {
			result[i] = r
		}
	}
	return result
}

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)
	xList := scanIntN(n)

	count := 0

	for _, v := range xList {
		if v%2 == 0 {
			count += 1
		} else {
			count -= 1
		}
	}

	fmt.Println(absInt(count))
}
0