QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 128 MB

#22975. Card Game

Statistics

Geunwoo is learning an interesting card game today.

Cards come in four colors: red, blue, yellow, and green. Each color has nine cards numbered from 1 to 9.

There are $36=4\times 9$ cards in total. In the game Geunwoo learned, five of the 36 cards are drawn, and an integer score is calculated using the rules below.

Each card is represented as follows. Its color is written as an uppercase English letter R, B, Y, or G, meaning red, blue, yellow, or green respectively. For example, Y8 means a yellow 8, and B5 means a blue 5.

Scoring rules

  1. If all five cards have the same color and consecutive numbers, the score is the highest number plus 900. For example: Y4, Y3, Y2, Y5, Y6 → $906=6+900$.

  2. If four of the five cards have the same number, the score is that number plus 800. For example: B3, R3, B7, Y3, G3 → $803=3+800$.

  3. If three cards have the same number and the other two also have the same number, multiply the number on the three cards by 10, add the number on the two cards, and then add 700. For example: R5, Y5, G7, B5, Y7 → $757=5\times 10+7+700$.

  4. If all five cards have the same color, the score is the highest number plus 600. For example: Y3, Y4, Y8, Y6, Y7 → $608=8+600$.

  5. If the five numbers are consecutive, the score is the highest number plus 500. For example: R7, R8, G9, Y6, B5 → $509=9+500$.

  6. If three of the five cards have the same number, the score is that number plus 400. For example: R7, Y7, R2, G7, R5 → $407=7+400$.

  7. If two cards have the same number and another two cards have the same number, multiply the larger of the two repeated numbers by 10, add the smaller, and then add 300. For example: R5, Y5, Y4, G9, B4 → $354=5\times 10+4+300$.

  8. If two of the five cards have the same number, the score is that number plus 200. For example: R5, Y2, B5, B3, G4 → $205=5+200$.

  9. If none of the above cases applies, the score is the highest number plus 100. For example: R1, R2, B4, B8, Y5 → $108=8+100$.

Given five cards, write a program to calculate the score of the card game. If two or more rules apply, the score is the highest obtainable score.

Input

The first through fifth lines each contain one card. A single space separates its color and number.

Output

Output the score on one line.

Examples

Input 1

B 3
B 7
R 1
B 2
Y 7

Output 1

207

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.