問題一覧 > 通常問題

No.161 Restricted Rock-Paper-Scissors

レベル : / AI推定難易度 : 550 / 実行時間制限 : 1ケース 5.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 335
作問者 : 👑 kmjp
お気に入りにしたユーザー ProblemId : 252 / 自分の提出
問題文最終更新日: 2026-06-25 07:18:24
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 90 (順位表) の他の問題:

Problem Statement

yuki-kun has decided to play restricted rock-paper-scissors with a friend.

In this restricted rock-paper-scissors, a total of N rounds of rock-paper-scissors are played (a draw also counts as one round).
Out of the N rounds, yuki-kun can play rock only G times, scissors only C times, and paper only P times.

yuki-kun earns 3 points for each round he wins and 1 point for each draw. A loss neither increases nor decreases his points.
Fortunately, yuki-kun was able to read all of his friend's moves in advance with his psychic powers.
Find the maximum total points yuki-kun can obtain over the N rounds when he plays optimally.

Input

\(G\) \(C\) \(P\)
\(S\)

G, C, P are integers representing the number of times yuki-kun can play rock, scissors, and paper, respectively.
S is a string representing the opponent's moves, consisting only of 'G', 'C', 'P'.
If the i-th character of S is 'G', 'C', or 'P', the opponent's move in the i-th round is rock, scissors, or paper, respectively.

The input satisfies \(1 \le |S| \le 300\) and \(|S| = G + C + P\).
Note that the numbers of rocks, scissors, and papers played by yuki-kun and his friend do not necessarily match.

Output

Output the maximum number of points yuki-kun can obtain, on one line.

Sample

Sample 1
Input
2 1 1
CCGP
Output
12

Playing rock, rock, paper, scissors in this order wins all four rounds.

Sample 2
Input
0 0 5
CCCCC
Output
0

He helplessly loses every round.

Sample 3
Input
7 6 5
GCPGPCPGGGPCCCGPGP
Output
50

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。