結果

問題 No.161 制限ジャンケン
ユーザー masamasa
提出日時 2015-03-06 14:23:43
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 723 bytes
コンパイル時間 690 ms
コンパイル使用メモリ 62,388 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-20 04:23:59
合計ジャッジ時間 1,350 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;

int main() {
	int mine[3] = {};
	int yours[3] = {};
	string s;

	cin >> mine[0] >> mine[1] >> mine[2];
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		switch (s[i]) {
			case 'G' : yours[0]++; break;
			case 'C' : yours[1]++; break;
			case 'P' : yours[2]++; break;
			default: break;
		}
	}

	int point = 0;
	// win
	for (int i = 0; i < 3; i++) {
		int idx_y = (i + 1) % 3;

		int wins = min(mine[i], yours[idx_y]);
		point += wins * 3;
		mine[i] -= wins;
		yours[idx_y] -= wins;
	}

	// draw
	for (int i = 0; i < 3; i++) {
		point += min(mine[i], yours[i]);
	}

	cout << point << endl;
	return 0;
}
0