TopCoder problem "TheBoringGameDivTwo" used in SRM 488 (Division II Level Three)



Problem Statement

    John and Brus are very bored. That's why they decided to invite their friend and play a boring shooter game. John and Brus are on the first team and the friend is the only player of the second team. The game consists of X rounds. During a round players may shoot each other, but a player can't shoot himself. If a player shoots some player from the opposite team his score is increased by one and if he shoots his teammate his score is decreased by one. Once a player is shot, he can't shoot other players and other players can't shoot him until the end of the current round. A round ends when all the players on one of the teams are shot.



You are given six integers. scoreJ, scoreB and scoreF are scores of John, Brus and the friend, respectively. killedJ, killedB and killedF are the number of times John, Brus and the friend were shot, respectively. Return the int[] containing exactly two elements, where the first element is the smallest possible value of X and the second element is the largest possible value of X. If there are no possible values of X, return an empty int[].
 

Definition

    
Class:TheBoringGameDivTwo
Method:find
Parameters:int, int, int, int, int, int
Returns:int[]
Method signature:int[] find(int scoreJ, int killedJ, int scoreB, int killedB, int scoreF, int killedF)
(be sure your method is public)
    
 

Constraints

-scoreJ will be between -47 and 47, inclusive.
-scoreB will be between -47 and 47, inclusive.
-scoreF will be between -47 and 47, inclusive.
-killedJ will be between 0 and 47, inclusive.
-killedB will be between 0 and 47, inclusive.
-killedF will be between 0 and 47, inclusive.
 

Examples

0)
    
1
1
1
1
2
2
Returns: {2, 3 }
The possible scenario with two rounds is: friend kills John, Brus kills friend, round ends, friend kills Brus, John kills friend, round ends. And with three rounds - John kills friend, round ends, Brus kills friend, round ends, friend kills John, friend kills Brus, round ends.
1)
    
0
0
0
0
0
0
Returns: {0, 0 }
No rounds here.
2)
    
4
7
-2
5
1
9
Returns: { }
This is impossible.
3)
    
1
5
-1
4
3
6
Returns: {8, 9 }

Problem url:

http://www.topcoder.com/stat?c=problem_statement&pm=11206

Problem stats url:

http://www.topcoder.com/tc?module=ProblemDetail&rd=14241&pm=11206

Writer:

Vasyl[alphacom]

Testers:

PabloGilberto , ivan_metelsky , nika

Problem categories:

Simple Search, Iteration, Simulation