結果

問題 No.161 制限ジャンケン
ユーザー tntantntan
提出日時 2016-04-04 00:12:43
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 548 bytes
コンパイル時間 1,422 ms
コンパイル使用メモリ 144,400 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-20 04:49:54
合計ジャッジ時間 2,368 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 2 ms
4,384 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,380 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 <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main()
{
	int a[3],sum=0,p[3]={};
	string s;
	cin>>a[0]>>a[1]>>a[2];
	cin>>s;
	for(int i=0;i<s.length();i++)
	{
		if(s[i]=='G')p[0]++;
		else if(s[i]=='C')p[1]++;
		else p[2]++;
	}
	int x[3]={min(a[0],p[1]),min(a[1],p[2]),min(a[2],p[0])};
	for(int i=0;i<3;i++)
	{
		sum+=3*x[i];
		a[i]-=x[i];
		p[(i+1)%3]-=x[i];
	}
	int y[3]={min(a[0],p[0]),min(a[1],p[1]),min(a[2],p[2])};
	for(int i=0;i<3;i++)
	{
		sum+=y[i];
		a[i]-=y[i];
		p[i]-=y[i];
	}
	cout<<sum<<endl;
	return 0;
}
0