結果

問題 No.161 制限ジャンケン
ユーザー ant2357ant2357
提出日時 2016-04-11 17:03:32
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 939 bytes
コンパイル時間 615 ms
コンパイル使用メモリ 65,408 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-15 00:13:54
合計ジャッジ時間 1,476 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <string>

using namespace std;

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

	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'G') {
			if (p > 0) {
				//パーを出して勝利
				p--;
				score += 3;
			} else if (g > 0) {
				//グーを出してあいこ
				g--;
				score += 1;
			} else {
				//チョキを出して敗北
				c--;
			}
		} else if (s[i] == 'C') {
			if (g > 0) {
				//グーを出して勝利
				g--;
				score += 3;
			} else if(c > 0) {
				//チョキを出してあいこ
				c--;
				score += 1;
			} else {
				//パーを出して敗北
				p--;
			}
		} else if(s[i] == 'P') {
			if (c > 0) {
				//チョキを出して勝利
				c--;
				score += 3;
			} else if(p > 0) {
				//パーを出してあいこ
				p--;
				score += 1;
			} else {
				//グーを出して敗北
				g--;
			}
		}
	}
	cout << score << endl;
	return 0;
}
0