Page not loading? Try clicking here.
Placeholder

#1311

Cards 1s 32MB

Problems

Geunwoo is learning a fun card game.

  • The game uses 36 cards, consisting of 4 colors: Red, Blue, Yellow, Green.

  • Each color has cards numbered 1 to 9.

  • Cards are represented as a color letter and a number:

    • R = Red

    • B = Blue

    • Y = Yellow

    • G = Green

  • For example, Y8 means Yellow 8, B5 means Blue 5.


Scoring Rules

You draw 5 cards, and calculate the score as follows:

  1. Five cards of the same color in consecutive numbers → score = 900 + highest number

    • Example: Y4, Y3, Y2, Y5, Y6 → 906

  2. Four cards with the same number → score = 800 + number of the four cards

    • Example: B3, R3, B7, Y3, G3 → 803

  3. Three cards of one number and two cards of another number → score = 700 + (3-number × 10 + 2-number)

    • Example: R5, Y5, G7, B5, Y7 → 757

  4. Five cards of the same color (not consecutive) → score = 600 + highest number

    • Example: Y3, Y4, Y8, Y6, Y7 → 608

  5. Five cards in consecutive numbers (not same color) → score = 500 + highest number

    • Example: R7, R8, G9, Y6, B5 → 509

  6. Three cards with the same number → score = 400 + that number

    • Example: R7, Y7, R2, G7, R5 → 407

  7. Two pairs of the same number → score = 300 + (larger pair × 10 + smaller pair)

    • Example: R5, Y5, Y4, G9, B4 → 354

  8. One pair of the same number → score = 200 + that number

    • Example: R5, Y2, B5, B3, G4 → 205

  9. None of the above → score = 100 + highest number

    • Example: R1, R2, B4, B8, Y5 → 108

If multiple rules apply, use the highest possible score.


Input

5 lines, each line contains a card in the format:
<Color Letter> <Number>

There is a space between the color letter and the number.


Output

One line containing the score of the hand.


Example

B 3

B 7
R 1
B 2
Y 7
207


Source

KOI 전국 2002 초1

You must sign in to write code.