結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 2 ms
4,348 KB
testcase_03 WA -
testcase_04 AC 1 ms
4,348 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
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;
	int dg, dc, dp;
	dg = min(g, eg);
	dc = min(c, ec);
	dp = min(p, ep);
	result = 3 * (dg, dc, dp);
	g -= dg;
	ec -= dg;
	c -= dc;
	ep -= dc;
	p -= dp;
	eg -= dp;

	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