結果

問題 No.161 制限ジャンケン
ユーザー IJMP320IJMP320
提出日時 2015-03-05 23:53:03
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,008 bytes
コンパイル時間 1,407 ms
コンパイル使用メモリ 147,776 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-20 04:22:29
合計ジャッジ時間 2,106 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int,int> pint;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const int INF = 100000000;
const int dx[4]={0,1,0,-1}, dy[4]={-1,0,1,0};
struct P{int x;int y;P(int X=0,int Y=0){x=X;y=Y;}};

int G,C,P;
string s;

int main() {
	char buf[301];
	cin >> G >> C >> P >> buf;
	s = buf;

	int ans = 0;
	sort(s.begin(), s.end());   // C G P
	rep(i,s.size()) {
		if(s[i] == 'C') {
			if(G > 0) {
				G--;
				ans += 3;
				s[i] = '#';
			}
		}
		else if(s[i] == 'G') {
			if(P > 0) {
				P--;
				ans += 3;
				s[i] = '#';
			}
		}
		else {
			if(C > 0) {
				C--;
				ans += 3;
				s[i] = '#';
			}
		}
	}

	rep(i,s.size()) {
		if(s[i] == '#') continue;
		if(s[i] == 'C') {
			if(C > 0) {
				C--;
				ans += 1;
				s[i] = '#';
			}
		}
		else if(s[i] == 'G') {
			if(G > 0) {
				G--;
				ans += 1;
				s[i] = '#';
			}
		}
		else {
			if(P > 0) {
				P--;
				ans += 1;
				s[i] = '#';
			}
		}
	}

	cout << ans << endl;
	return 0;
}
0