結果

問題 No.99 ジャンピング駒
ユーザー t_muranot_murano
提出日時 2016-06-11 15:42:29
言語 Go
(1.21.3)
結果
RE  
実行時間 -
コード長 751 bytes
コンパイル時間 11,993 ms
コンパイル使用メモリ 212,124 KB
実行使用メモリ 4,388 KB
最終ジャッジ日時 2023-08-01 13:30:00
合計ジャッジ時間 12,168 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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"
	"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