結果

問題 No.161 制限ジャンケン
ユーザー 184184
提出日時 2015-03-05 23:33:29
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 3 ms / 5,000 ms
コード長 586 bytes
コンパイル時間 576 ms
コンパイル使用メモリ 62,200 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-20 04:21:12
合計ジャッジ時間 1,412 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;

//namaega184
  
int main(){
	int g,c,p;char s[501];scanf("%d%d%d%s",&g,&c,&p,s);
	int gg=0,cc=0,pp=0; 
	int len=strlen(s);
	
	int ans=0;
	for(int i=0;i<len;i++){
		if(s[i]=='G')gg++;
		else if(s[i]=='C')cc++;
		else pp++;
	}
	
	int tmp=min(p,gg);
	ans+=tmp*3;
	p-=tmp,gg-=tmp;
	tmp=min(g,cc);
	ans+=tmp*3;
	g-=tmp,cc-=tmp;
	tmp=min(c,pp);
	ans+=tmp*3;
	c-=tmp,pp-=tmp;
	
	printf("%d\n",ans+min(g,gg)+min(p,pp)+min(c,cc));
	
	return 0;

}
0