TopcoderARCHIVE
Archive/Problems/BarongAndRangda
SRM · Problem 17782

BarongAndRangda

Problem statement, definition, constraints, and public examples.

Problem Statement

Barong and Rangda are characters from Balinese mythology. Barong, the king of spirits, represents good, while Rangda, the demon queen, represents evil.

We know that Barong is stronger than Rangda.


While traveling in Bali, we were pondering hypothetical fights between two teams, each consisting of some Barongs and some Rangdas.

Suppose there are two teams:

  • Team 1 consists of B1 Barongs and R1 Rangdas.
  • Team 2 consists of B2 Barongs and R2 Rangdas.

Consider the following statement: "Team 1 is stronger than team 2."

There are three possible scenarios, listed below. Determine which scenario occurs and return the corresponding message. (See Notes below if you need a more formal definition of the problem.)

  • If we can be sure that the statement is correct, return "correct".
  • If we can be sure that the statement is not correct, return "incorrect".
  • In all other cases, return "unknown".

Definition

Class:
BarongAndRangda
Method:
compare
Parameters:
int, int, int, int
Returns:
String
Method signature:
String compare(int B1, int R1, int B2, int R2)
(be sure your method is public)

Notes

  • All Barongs on both teams are identical copies of the same Barong and thus they all have the same strength: a positive real number b.
  • The same is true about all the Rangdas: the strength of each Rangda is the same positive real number r.
  • We don't know the exact values of b and r, we only know that b > r.
  • The strength of a team is the sum of the strengths of individuals that form the team.

Constraints

  • B1 will be between 0 and 10^8, inclusive.
  • R1 will be between 0 and 10^8, inclusive.
  • B2 will be between 0 and 10^8, inclusive.
  • R2 will be between 0 and 10^8, inclusive.

Examples

  1. 1
    0
    0
    1
    Returns: "correct"
    Team 1 has one Barong, team 2 has one Rangda. Team 1 is obviously stronger than team 2.
  2. 0
    1
    1
    0
    Returns: "incorrect"
    Team 1 has one Rangda, team 2 has one Barong. The statement "Team 1 is stronger than team 2." is obviously false.
  3. 0
    0
    0
    0
    Returns: "incorrect"
    Both teams are empty, and thus they have the exact same strength. Therefore the statement "Team 1 is stronger than team 2." is false.
  4. 4
    7
    1
    1
    Returns: "correct"
    A team with 4 Barongs and 7 Rangdas is clearly stronger than a team with just one being of each type.
  5. 9
    0
    0
    10
    Returns: "unknown"
    Are 9 Barongs stronger than 10 Rangdas? We don't know: it's possible that they are, but it's also possible that they aren't.
← All problems