The game of billiards involves two players knocking 3 balls around on a green baize table. Well, there is more to it, but for our purposes this is sufficient.The game consists of several rounds and in each round both players obtain a score, based on how well they played. Once all the rounds have been played, the total score of each player is determined by adding up the scores in all the rounds and the player with the higher total score is declared the winner.The Siruseri Sports Club organises an annual billiards game where the top two players of Siruseri play against each other. The Manager of Siruseri Sports Club decided to add his own twist to the game by changing the rules for determining the winner. In his version, at the end of each round, the cumulative score for each player is calculated, and the leader and her current lead are found. Once all the rounds are over the player who had the maximum lead at the end of any round in the game is declared the winner.Consider the following score sheet for a game with 5 rounds:Round Player 1 Player 21 140 822 89 1343 90 1104 112 1065 88 90The total scores of both players, the leader and the lead after each round for this game is given below:Round Player 1 Player 2 Leader Lead1 140 82 Player 1 582 229 216 Player 1 133 319 326 Player 2 74 431 432 Player 2 15 519 522 Player 2 3Note that the above table contains the cumulative scores.The winner of this game is Player 1 as he had the maximum lead (58 at the end of round 1) during the game.Your task is to help the Manager find the winner and the winning lead. You may assume that the scores will be such that there will always be a single winner. That is, there are no ties.InputThe first line of the input will contain a single integer N (N ≤ 10000) indicating the number of rounds in the game. Lines 2,3,...,N+1 describe the scores of the two players in the N rounds. Line i+1 contains two integer Si and Ti, the scores of the Player 1 and 2 respectively, in round i. You may assume that 1 ≤ Si ≤ 1000 and 1 ≤ Ti ≤ 1000.OutputYour output must consist of a single line containing two integers W and L, where W is 1 or 2 and indicates the winner and L is the maximum lead attained by the winner.Sample 1:InputOutput5140 8289 13490 110112 10688 901 58
Question
The game of billiards involves two players knocking 3 balls around on a green baize table. Well, there is more to it, but for our purposes this is sufficient.The game consists of several rounds and in each round both players obtain a score, based on how well they played. Once all the rounds have been played, the total score of each player is determined by adding up the scores in all the rounds and the player with the higher total score is declared the winner.The Siruseri Sports Club organises an annual billiards game where the top two players of Siruseri play against each other. The Manager of Siruseri Sports Club decided to add his own twist to the game by changing the rules for determining the winner. In his version, at the end of each round, the cumulative score for each player is calculated, and the leader and her current lead are found. Once all the rounds are over the player who had the maximum lead at the end of any round in the game is declared the winner.Consider the following score sheet for a game with 5 rounds:Round Player 1 Player 21 140 822 89 1343 90 1104 112 1065 88 90The total scores of both players, the leader and the lead after each round for this game is given below:Round Player 1 Player 2 Leader Lead1 140 82 Player 1 582 229 216 Player 1 133 319 326 Player 2 74 431 432 Player 2 15 519 522 Player 2 3Note that the above table contains the cumulative scores.The winner of this game is Player 1 as he had the maximum lead (58 at the end of round 1) during the game.Your task is to help the Manager find the winner and the winning lead. You may assume that the scores will be such that there will always be a single winner. That is, there are no ties.InputThe first line of the input will contain a single integer N (N ≤ 10000) indicating the number of rounds in the game. Lines 2,3,...,N+1 describe the scores of the two players in the N rounds. Line i+1 contains two integer Si and Ti, the scores of the Player 1 and 2 respectively, in round i. You may assume that 1 ≤ Si ≤ 1000 and 1 ≤ Ti ≤ 1000.OutputYour output must consist of a single line containing two integers W and L, where W is 1 or 2 and indicates the winner and L is the maximum lead attained by the winner.Sample 1:InputOutput5140 8289 13490 110112 10688 901 58
Solution
The problem is asking to find the winner of a modified billiards game. The winner is determined by the player who had the maximum lead at the end of any round in the game, not the total score at the end of the game.
Here is a step-by-step solution:
-
Initialize two variables,
max_leadandwinner, to keep track of the maximum lead and the player who had this lead. -
Read the number of rounds
N. -
Loop over the range
Nand for each round do the following:-
Read the scores of Player 1 and Player 2.
-
Calculate the cumulative score for each player.
-
Calculate the lead of the current round by subtracting the cumulative score of Player 2 from that of Player 1.
-
If the absolute value of the current lead is greater than
max_lead, updatemax_leadwith the absolute value of the current lead and updatewinnerwith 1 if the lead is positive, otherwise update it with 2.
-
-
Print
winnerandmax_lead.
This solution assumes that the scores will be such that there will always be a single winner, i.e., there are no ties.
Similar Questions
Two friends, Neha and Sneha, decided to play the game pockets billiard on their holiday. This game is similar to the carom game, except but it has 6 holes on the board to strike the balls into it. This game consists of 15 numbered color balls, and 1 cue ball, which is used to strike the other 15 numbered color balls to the holes. These balls are arranged in the pyramid form. The first player strikes them using the white ball(cue ball) to break the formation and then tries to sink the ball into the holes. Each player takes alternate turns to strike the balls. (Note: Ignore the cue ball while taking the total number of balls.) 1. If Neha plays first, then the probability that she successfully sinks the ball numbered 10 is1212151151015 2. If Sneha plays secondly without replacing the ball 10, then the probability that Sneha sink the ball numbered 13 is11410151315115 3. The probability that Neha sinks a ball is an odd number is1315114115815 4. The probability that Sneha sinks a ball is a number divisible by 6 is215115114815 5. The probability that Sneha sinks a ball is a number not divisible by 6 is1315215115114
Billiards ____ my cousin'sfavorite sport.A. willB. isC. areD. am
Players score points by striking a shuttlecock with their racket so that it passes over the net and lands in their opponents' half of the court. 1 pointTABLE TENNISBADMINTONRACKET SPORTSLAWN TENNIS
Strategy Design:• Design and describe two different strategies that players can employ in this dynamic game.• Consider strategies such as always attacking, always defending, random choices, orconditional choices based on opponents' actions.Geometric Progression Analysis:• Explain how geometric progression can be applied to calculate the winning probabilities ofeach player over multiple rounds of the game.• Develop an equation for calculating the probability of each player winning after 'n' roundsusing a geometric progression formula for both strategies. Consider factors like the initialprobabilities, strategy changes, and game outcomes.Strategy Comparison and Discussion:• Analyze and compare the results from the geometric progression equations for the twodifferent strategies. Discuss the effectiveness of each strategy in terms of maximizing aplayer's winning probability.Computational Theory - Assignment 03 33
This is a great book to take a trip to the exciting world of tennis, to see how this game appeared and developed from ancient times to the present day, to learn its idea and rules, as well as to learn a tennis court, racket, ball, clothes, etc.
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.