結果

問題 No.161 制限ジャンケン
ユーザー dgd1724dgd1724
提出日時 2016-10-30 18:33:57
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 917 bytes
コンパイル時間 4,031 ms
コンパイル使用メモリ 145,344 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-20 04:57:21
合計ジャッジ時間 2,949 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

//const static double	de_PI	= 3.14159265358979323846;
//const static int	de_MOD	= 1000000007;
//const static int	de_MAX	= 999999999;
//const static int	de_MIN = -999999999;

int main(void) {

	//std::ifstream in("123.txt");	std::cin.rdbuf(in.rdbuf());	

	int g1 = 0, c1 = 0, p1 = 0;
	int g2 = 0, c2 = 0, p2 = 0;
	std::string S;
	std::cin >> g1 >> c1 >> p1 >> S;

	g2 = std::count(S.begin(), S.end(), 'G');
	c2 = std::count(S.begin(), S.end(), 'C');
	p2 = S.length() - g2 - c2;

	int ans = 0;

	while (g1 != 0 && c2 != 0) {
		g1--;
		c2--;
		ans += 3;
	}

	while (c1 != 0 && p2 != 0) {
		c1--;
		p2--;
		ans += 3;
	}

	while (p1 != 0 && g2 != 0) {
		p1--;
		g2--;
		ans += 3;
	}

	while (g1 != 0 && g2 != 0) {
		g1--;
		g2--;
		ans++;
	}

	while (c1 != 0 && c2 != 0) {
		c1--;
		c2--;
		ans++;
	}

	while (p1 != 0 && p2 != 0) {
		p1--;
		p2--;
		ans++;
	}

	std::cout << ans << std::endl;
}

0