結果

問題 No.99 ジャンピング駒
ユーザー t_murano
提出日時 2016-06-11 15:42:29
言語 Go
(1.23.4)
結果
RE  
実行時間 -
コード長 751 bytes
コンパイル時間 12,191 ms
コンパイル使用メモリ 219,368 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-10-11 05:12:52
合計ジャッジ時間 12,805 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other RE * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

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

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

func nextIntList(sc *bufio.Scanner) []int {
	sc.Scan()
	input := strings.Split(sc.Text(), " ")
	result := make([]int, len(input))
	for i, v := range input {
		if j, e := strconv.Atoi(v); e != nil {
			panic(e)
		} else {
			result[i] = j
		}
	}
	return result
}

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

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

	nextInt(sc)
	xList := nextIntList(sc)
	count := 0

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

	fmt.Println(absInt(count))
}
0