結果

問題 No.161 制限ジャンケン
ユーザー sekiya9311sekiya9311
提出日時 2016-06-06 15:22:15
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,586 bytes
コンパイル時間 1,045 ms
コンパイル使用メモリ 118,296 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-20 04:51:46
合計ジャッジ時間 1,894 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <random>

#define REP(i,n) for(long (i)=0;(i)<(n);(i)++)
#define FOR(i,a,b) for(long (i)=(a);(i)<(b);(i)++)
#define RREP(i,a) for(long (i)=(a)-1;(i)>=0;(i)--)
#define FORR(i,a,b) for(long (i)=(a)-1;(i)>=(b);(i)--)
#define MOD 1000000007
#define PI acos(-1.0)
#define DEBUG(C) cout<<C<<endl;
#define PII pair<int,int>
#define PLL pair<long,long>
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define RSORT(a) sort((a).begin(),(a).end(),greater<int>())

typedef long long LL;
typedef unsigned long long ULL;

using namespace std;

int main(void){
	map<char,int> mp;
	int jan[3]; REP(i,3) cin>>jan[i];
	char h[3]={'G','C','P'};REP(i,3) mp[h[i]]=0;
	string s; cin>>s;
	REP(i,s.size()) mp[s[i]]++;
	int w=0,l=0,ans=0;
	REP(i,3){
		int ww=min(mp[h[(i+1)%3]],jan[i]);
		if(ww==mp[h[(i+1)%3]]){
			mp[h[(i+1)%3]]=0;
			jan[i]-=ww;
		}else{
			jan[i]=0;
			mp[h[(i+1)%3]]-=ww;
		}
		w+=ww; //DEBUG(ww);
	}
	REP(i,3){
		int num=min(mp[h[i]],jan[i]);
		if(num==mp[h[i]]){
			mp[h[i]]=0;
			jan[i]-=num;
		}else{
			jan[i]=0;
			mp[h[i]]-=num;
		}
		ans+=num; //DEBUG(num);
	}
	ans+=w*3;
	cout<<ans<<endl;
}
0