結果

問題 No.99 ジャンピング駒
ユーザー t_muranot_murano
提出日時 2016-06-11 16:01:43
言語 Go
(1.22.1)
結果
RE  
実行時間 -
コード長 709 bytes
コンパイル時間 13,350 ms
コンパイル使用メモリ 227,680 KB
実行使用メモリ 7,796 KB
最終ジャッジ日時 2024-04-19 12:53:07
合計ジャッジ時間 21,164 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 scanlnInt(n int) []int {
	x := make([]int, n)
	y := make([]interface{}, len(x))
	for i := range x {
		y[i] = &x[i]
	}
	n, e := fmt.Scanln(y...)
	if e != nil {
		panic(e)
	}
	x = x[:n]
	return x
}

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

	count := 0

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

	fmt.Println(absInt(count))
}
0