結果

問題 No.161 制限ジャンケン
ユーザー ant2357ant2357
提出日時 2016-04-11 18:14:40
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 746 bytes
コンパイル時間 555 ms
コンパイル使用メモリ 68,456 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-15 00:15:58
合計ジャッジ時間 1,305 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main() {
	int g, c, p;
	int enemyG = 0, enemyC = 0, enemyP = 0;
	int score = 0;
	string s;
	cin >> g >> c >> p >> s;

	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'G') {
			enemyG++;
		} else if (s[i] == 'C') {
			enemyC++;
		} else if(s[i] == 'P') {
			enemyP++;
		}
	}

	int gWin = min(g, enemyC);
	int cWin = min(c, enemyP);
	int pWin = min(p, enemyG);

	g -= gWin, enemyC -= gWin;
	c -= cWin, enemyP -= cWin;
	p -= pWin, enemyG -= pWin;

	score += 3 * (gWin + cWin + pWin);

	int gDraw, cDraw, pDraw;

	gDraw = min(g, enemyG);
	cDraw = min(c, enemyC);
	pDraw = min(c, enemyP);

	score += gDraw + cDraw + pDraw;
	
	cout << score << endl;
	return 0;
}
0