結果

問題 No.161 制限ジャンケン
ユーザー tnoda_tnoda_
提出日時 2015-03-18 18:16:55
言語 Go
(1.22.1)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 511 bytes
コンパイル時間 14,659 ms
コンパイル使用メモリ 202,988 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-08-20 04:26:47
合計ジャッジ時間 15,506 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

package main

import (
	"fmt"
)

func min(x, y int) int {
	if y < x {
		return y
	}
	return x
}

func main() {
	var G, C, P, oG, oC, oP, gWin, cWin, pWin int
	var S string
	fmt.Scan(&G, &C, &P, &S)
	for _, r := range S {
		switch r {
		case 'G':
			oG++
		case 'C':
			oC++
		case 'P':
			oP++
		}
	}
	gWin, cWin, pWin = min(G, oC), min(C, oP), min(P, oG)
	G -= gWin
	oC -= gWin
	C -= cWin
	oP -= cWin
	P -= pWin
	oG -= pWin
	res := 3*(gWin+cWin+pWin) + min(G, oG) + min(C, oC) + min(P, oP)
	fmt.Println(res)
}
0