結果

問題 No.161 制限ジャンケン
ユーザー KUddb
提出日時 2016-02-28 10:57:20
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 807 bytes
コンパイル時間 456 ms
コンパイル使用メモリ 57,792 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-30 04:50:12
合計ジャッジ時間 1,189 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

// ConsoleApplication1.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;


void f(string s, int *S) {
	S[0] = 0;
	S[1] = 0;
	S[2] = 0;
	for (int i = 0; i < s.length(); i++) {
		if (s[i] == 'G') {
			S[0]++;
		}
		else if (s[i] == 'C') {
			S[1]++;
		}
		else if(s[i]=='P'){
			S[2]++;
		}
	}
}



int main()
{
	int g,c,p;
	cin >> g >> c >> p;
	string s;
	int *S = new int[3];
	cin >> s;
	f(s, S);
	int N = 0;
	int x, y, z;
	x = min(g, S[1]);
	y = min(c, S[2]);
	z = min(p, S[0]);
	g -= x;
	S[1] -= x;
	c -= y;
	S[2] -= y;
	p -= z;
	S[0] -= z;
	N += 3 * (x + y + z);
	int X,Y,Z;
	X = min(g, S[0]);
	Y = min(c, S[1]);
	Z = min(p, S[2]);
	N += 1 * (X+Y+Z);
	cout << N;

	return 0;
}
0