TheBoringGameDivTwo
SRM 488 · 2010-03-12 · by Vasyl[alphacom]
SRM 488 · 2010-03-12 · by Vasyl[alphacom] · Math, Simple Search, Iteration, Simulation
Problem Statement
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 theint[] 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[] .
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
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 }
4)
-2
5
-10
0
8
1
Returns: { }
Submissions are judged against all 64 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Coding Area
Language: C++17 · define a public class TheBoringGameDivTwo with a public method vector<int> find(int scoreJ, int killedJ, int scoreB, int killedB, int scoreF, int killedF) · 64 test cases · 2 s / 256 MB per case