結果

問題 No.161 制限ジャンケン
ユーザー めうめう🎒めうめう🎒
提出日時 2016-03-28 00:26:13
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,003 bytes
コンパイル時間 665 ms
コンパイル使用メモリ 73,064 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-20 04:48:16
合計ジャッジ時間 1,547 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define ll long long
#define INF (1 << 30)
#define INFLL (1LL << 60)

int main() {
	int g_y = 0,c_y = 0,p_y = 0,g_f = 0,c_f = 0,p_f = 0;
	string str;
	cin >> g_y >> c_y >> p_y;
	cin >> str;
	for(int i = 0;i < str.size();i++){
		if(str[i] == 'G') g_f++;
		else if(str[i] == 'C') c_f++;
		else if(str[i] == 'P') p_f++;
	}
	int point = 0;
	if(g_y >= c_f) {
		point += 3 * c_f;
		g_y -= c_f;
		c_f = 0;
	}else{
		point += 3 * g_y;
		c_f -= g_y;
		g_y = 0;
	}

	if(c_y >= p_f){
		point += 3 * p_f;
		c_y -= p_f;
		p_f = 0;
	}else{
		point += 3 * c_y;
		p_f -= c_y;
		c_y = 0;
	}

	if(p_y >= g_f){
		point += 3 * g_f;
		p_y -= g_f;
		g_f = 0;
	}else{
		point += 3 * p_y;
		g_f -= p_y;
		p_y = 0;
	}

	point += min(g_f,g_y) + min(c_y,c_f) + min(p_y,p_f);

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