結果

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
#include <string>
#include <climits>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,x,n) for(int i=x;i<n;i++)
#define ALL(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<":"<<x<<endl
const int INF = INT_MAX / 3;

int main(){
	int G, C, P; cin >> G >> C >> P;
	string S; cin >> S;
	int gg = 0, cc = 0, pp = 0;
	rep(i, S.size()){
		if (S[i] == 'C') cc++;
		else if (S[i] == 'G') gg++;
		else if (S[i] == 'P') pp++;
	}
	int ans = 0;
	int my_g, my_c, my_p;
	my_g = min(G, cc);
	G -= my_g;
	cc -= my_g;
	my_c = min(C, pp);
	C -= my_c;
	pp -= my_c;
	my_p = min(P, gg);
	P -= my_p;
	gg -= my_p;
	ans += 3 * (my_c + my_g + my_p);
	ans += min(gg, G);
	ans += min(pp, P);
	ans += min(cc, C);
	cout << ans << endl;
	return 0;
}
0