結果

問題 No.161 制限ジャンケン
ユーザー yuki2006yuki2006
提出日時 2015-03-05 14:51:50
言語 Go1.4
(1.4.2)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 943 bytes
コンパイル時間 2,692 ms
コンパイル使用メモリ 32,772 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-20 04:19:40
合計ジャッジ時間 3,620 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

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

var s = bufio.NewScanner(os.Stdin)

func next() string {
	s.Split(bufio.ScanWords)
	s.Scan()
	return s.Text()
}

func nextInt() int {
	i, e := strconv.Atoi(next())
	if e != nil {
		panic(e)
	}
	return i
}
func nextLong() int64 {
	i, e := strconv.ParseInt(next(), 10, 64)
	if e != nil {
		panic(e)
	}
	return i
}
func main() {
	D := [3]int{}
	D[0] = nextInt()
	D[1] = nextInt()
	D[2] = nextInt()

	S := next()
	checked := make([]bool, len(S))
	point := 0

	for k := -1; k < 2; k++ {
		for i := 0; i < len(S); i++ {
			if checked[i]{
				continue
			}
			var P = 0
			switch {
			case S[i] == 'G':
				P = 0
			case S[i] == 'C':
				P = 1
			case S[i] == 'P':
				P = 2
			}

			p := (P + k + 3) % 3
			if D[p] > 0 {
				D[p]-=1
				if k == -1 {
					point+=3
					checked[i] = true

				}else if k == 0 {
					point+=1
					checked[i] = true
				}

			}
		}
	}

	fmt.Println(point)

}
0