103620: [Atcoder]ABC362 A - Buy a Pen

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:10 Solved:0

Description

Score : $100$ points

Problem Statement

Takahashi came to a store to buy a pen. Here, a red pen costs $R$ yen, a green pen costs $G$ yen, and a blue pen costs $B$ yen.

Takahashi dislikes the color $C$. If $C$ is Red, he cannot buy a red pen; if $C$ is Green, he cannot buy a green pen; and if $C$ is Blue, he cannot buy a blue pen.

Determine the minimum amount of money he needs to buy one pen.

Constraints

  • $ 1\leq R,G,B\leq 100$
  • $R$, $G$, and $B$ are integers.
  • $C$ is Red, Green, or Blue.

Input

The input is given from Standard Input in the following format:

$R$ $G$ $B$
$C$

Output

If the minimum amount of money Takahashi needs to buy one pen is $X$ yen, print $X$.


Sample Input 1

20 30 10
Blue

Sample Output 1

20

A red pen costs $20$ yen, a green pen costs $30$ yen, and a blue pen costs $10$ yen. Takahashi cannot buy a blue pen, but he can buy a red pen for $20$ yen.


Sample Input 2

100 100 100
Red

Sample Output 2

100

Sample Input 3

37 39 93
Blue

Sample Output 3

37

Output

得分:100分

问题陈述

高桥来到一家商店买笔。在这里,红色笔的价格是R日元,绿色笔的价格是G日元,蓝色笔的价格是B日元。

高桥不喜欢颜色C。如果C是Red,他不能买红色笔;如果C是Green,他不能买绿色笔;如果C是Blue,他不能买蓝色笔。

确定他买一支笔所需的最少金额。

约束条件

  • $ 1\leq R,G,B\leq 100$
  • R、G和B都是整数。
  • C是RedGreenBlue

输入

输入从标准输入以下格式给出:

R G B
C

输出

如果高桥买一支笔所需的最少金额是X日元,则打印X。


样本输入1

20 30 10
Blue

样本输出1

20

红色笔的价格是20日元,绿色笔的价格是30日元,蓝色笔的价格是10日元。高桥不能买蓝色笔,但他可以用20日元买红色笔。


样本输入2

100 100 100
Red

样本输出2

100

样本输入3

37 39 93
Blue

样本输出3

37

加入题单

上一题 下一题 算法标签: