結果

問題 No.161 制限ジャンケン
ユーザー olpheolphe
提出日時 2017-06-11 01:30:38
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,279 bytes
コンパイル時間 1,195 ms
コンパイル使用メモリ 109,692 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-20 05:03:08
合計ジャッジ時間 2,195 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "random"

using namespace std;
const long long int MOD = 1000000007;
list<long long int> Prime(int M) {
	list<long long int>P;
	P.push_back(2);
	P.push_back(3);
	for (int i = 5; i <= M; i += 6) {
		bool flag = true;
		for (auto j : P) {
			if (i%j == 0) {
				flag = false;
				break;
			}
		}
		if (flag)P.push_back(i);
		flag = true;
		for (auto j : P) {
			if ((i + 2) % j == 0) {
				flag = false;
				break;
			}
		}
		if (flag)P.push_back(i + 2);
	}
	return P;
}

long long int N, M, K, Q;
long long int ans;

int g, c, p;
int G, C, P;
string s;
int box;

int main() {
	ios::sync_with_stdio(false);
	cin >> g >> c >> p;
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'G')G++;
		if (s[i] == 'C')C++;
		if (s[i] == 'P')P++;
	}
	box = min(g, C);
	ans += 3 * box;
	g -= box;
	C -= box;
	box = min(c, P);
	ans += 3 * box;
	c -= box;
	P -= box;
	box = min(p, G);
	ans += 3 * box;
	p -= box;
	G -= box;
	ans += min(g, G);
	ans += min(p, P);
	ans += min(c, C);
	cout << ans << endl;
	return 0;
}
0