結果

問題 No.161 制限ジャンケン
ユーザー kongarishisyamokongarishisyamo
提出日時 2016-04-16 15:53:17
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 753 bytes
コンパイル時間 390 ms
コンパイル使用メモリ 52,360 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-20 04:50:07
合計ジャッジ時間 1,359 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<string>

using namespace std;

int main(){

	int G,C,P;
	string S;
	int Ge=0,Ce=0,Pe=0;
	int ans=0;

	cin>>G>>C>>P;
	cin>>S;

	for(int i=0;i<S.size();i++){
		if(S[i]=='C') Ce++;
		else if(S[i]=='G') Ge++;
		else Pe++;
	}

	if(G>Ce){
		G-=Ce;
		ans+=Ce*3;
		Ce=0;
	}
	else{
		Ce-=G;
		ans+=G*3;
		G=0;
	}
	if(C>Pe){
		C-=Pe;
		ans+=Pe*3;
		Pe=0;
	}
	else{
		Pe-=C;
		ans+=C*3;
		C=0;
	}
	if(P>Ge){
		P-=Ge;
		ans+=Ge*3;
		Ge=0;
	}
	else{
		Ge-=P;
		ans+=P*3;
		P=0;
	}

	if(G>Ge){
		G-=Ge;
		ans+=Ge;
		Ge=0;
	}
	else{
		Ge-=G;
		ans+=G;
		G=0;
	}
	if(C>Ce){
		C-=Ce;
		ans+=Ce;
		Ce=0;
	}
	else{
		Ce-=C;
		ans+=C;
		C=0;
	}
	if(P>Pe){
		P-=Pe;
		ans+=Pe;
		Pe=0;
	}
	else{
		Pe-=P;
		ans+=P;
		P=0;
	}

	cout<<ans<<endl;
}

0