結果

問題 No.161 制限ジャンケン
ユーザー nablaenergy_21nablaenergy_21
提出日時 2015-05-25 01:45:11
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 568 bytes
コンパイル時間 705 ms
コンパイル使用メモリ 25,684 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-20 04:30:57
合計ジャッジ時間 1,645 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<stdio.h>

int min(int a,int b){
	if(a<b){return a;}else{return b;}
}

int main(void){
	int G,C,P;
	char S[301];
	int i,G2,C2,P2,ans;

	scanf("%d %d %d",&G,&C,&P);
	scanf("%s",S);

	G2=0;C2=0;P2=0;
	for(i=0;i<G+C+P;i++){
		if(S[i]=='G'){G2++;}
		if(S[i]=='C'){C2++;}
		if(S[i]=='P'){P2++;}
	}

	ans = 0;

	i = min(G,C2);
	ans = ans + i*3;
	G = G - i;
	C2 = C2 - i;

	i = min(C,P2);
	ans = ans + i*3;
	C = C - i;
	P2 = P2 - i;

	i = min(P,G2);
	ans = ans + i*3;
	P = P - i;
	G2 = G2 - i;

	ans = ans + min(P,P2) + min(G,G2) + min(C,C2);

	printf("%d\n",ans);

}
0