結果

問題 No.161 制限ジャンケン
ユーザー TatamoTatamo
提出日時 2016-02-23 21:27:49
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 788 bytes
コンパイル時間 538 ms
コンパイル使用メモリ 59,188 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-23 19:29:55
合計ジャッジ時間 2,060 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<algorithm>
#include<string>
using namespace std;

// problems/252
int main() {
	int g, c, p;
	cin >> g >> c >> p;

	string s;
	cin >> s;

	int eg, ec, ep;
	eg = ec = ep = 0;
	for (int i = 0; i < s.length(); i++) {
		if (s[i] == 'G')  eg += 1;
		else if (s[i] == 'C')  ec += 1;
		else if (s[i] == 'P')  ep += 1;
	}

	//cout << g << " " << c << " " << p << endl;
	//cout << eg << " " << ec << " " << ep << endl;

	int result;
	result = 3 * (min(g, ec) + min(c, ep) + min(p, eg));
	g -= min(g, ec);
	ec -= min(g, ec);
	c -= min(c, ep);
	ep -= min(c, ep);
	p -= min(p, eg);
	eg -= min(p, eg);

	if (eg > 0 && g > 0) result += min(g, eg);
	if (ec > 0 && c > 0) result += min(c, ec);
	if (ep > 0 && p > 0) result += min(p, ep);

	cout << result << endl;
	return 0;
}
0