結果

問題 No.161 制限ジャンケン
ユーザー kkslucy1kkslucy1
提出日時 2018-03-13 03:27:11
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 592 bytes
コンパイル時間 1,311 ms
コンパイル使用メモリ 158,960 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-28 12:24:56
合計ジャッジ時間 1,809 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
	int g[3];
	cin >> g[0]>>g[1]>>g[2];
	string s;
	cin >> s;
	int g2[3]={ 0 };
	for (int i = 0;i < s.size();i++) {
		switch (s[i]) {
		case 'G':
			g2[0]++;
			break;
		case 'C':
			g2[1]++;
			break;
		case 'P':
			g2[2]++;
			break;
		}
	}
	int ans = 0;
	int d2[] = { 1,2,0 };
	for (int i = 0;i < 3;i++) {
		int mi = min(g[i], g2[d2[i]]);
		g[i] -= mi;
		g2[d2[i]] -= mi;
		ans += 3 * mi;
	}
	for (int i = 0;i < 3;i++) {
		int mi = min(g[i], g2[i]);
		g[i] -= mi;
		g2[i] -= mi;
		ans += mi;
	}
	cout << ans << endl;

	return 0;


}
0