結果

問題 No.161 制限ジャンケン
ユーザー chakkuchakku
提出日時 2015-09-26 02:36:57
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 838 bytes
コンパイル時間 651 ms
コンパイル使用メモリ 67,200 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-20 04:42:12
合計ジャッジ時間 1,547 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 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 2 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,376 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,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

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