結果

問題 No.161 制限ジャンケン
ユーザー やまぞう
提出日時 2015-03-25 01:27:16
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 936 bytes
コンパイル時間 401 ms
コンパイル使用メモリ 55,008 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-30 04:31:41
合計ジャッジ時間 1,175 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int yukiG, yukiC, yukiP;
string S;
int tomoG, tomoC, tomoP;

void input(istream& in)
{
	in >> yukiG >> yukiC >> yukiP;
	in >> S;
}

int resolve()
{
	tomoG = tomoC = tomoP = 0;
	for (char ch : S) {
		switch (ch) {
		case 'G': tomoG++; break;
		case 'C': tomoC++; break;
		case 'P': tomoP++; break;
		}
	}

	int score = 0;
	int tmp;

	tmp = (yukiG < tomoC) ? yukiG : tomoC;
	yukiG -= tmp;
	tomoC -= tmp;
	score += 3 * tmp;

	tmp = (yukiC < tomoP) ? yukiC : tomoP;
	yukiC -= tmp;
	tomoP -= tmp;
	score += 3 * tmp;

	tmp = (yukiP < tomoG) ? yukiP : tomoG;
	yukiP -= tmp;
	tomoG -= tmp;
	score += 3 * tmp;

	tmp = (yukiG < tomoG) ? yukiG : tomoG;
	score += tmp;

	tmp = (yukiC < tomoC) ? yukiC : tomoC;
	score += tmp;

	tmp = (yukiP < tomoP) ? yukiP : tomoP;
	score += tmp;

	return score;
}

int main(int argc, char **argv)
{
	input(cin);
	cout << resolve() << endl;
	return 0;
}
0