codechef solution in c++,codechef problem solutions,codechef solutions,codechef solutions in hindi,cpp codechef solution,codechef lunchtime,codechef long solutions,codechef beginner solutions,#codechef solution,codechef tutorial,codechef division 1,problem walkthrough,codechef cookoff,codechef problems solutions c,codechef easy problem solve,solution of codechef problem,solutions of codechef problem,problem solving,shorts,ytshorts,viral,codechef,shortvideo, REACHTARGET,
Reach the Target
Difficulty Rating:281
Expand
Prev
Next
Problem
There is a cricket match going on between two teams
�
A and
�
B.
Team
�
B is batting second and got a target of
�
X runs. Currently, team
�
B has scored
�
Y runs. Determine how many more runs Team
�
B should score to win the match.
Note: The target score in cricket matches is one more than the number of runs scored by the team that batted first.
Input Format
The first line of input will contain a single integer
�
T, denoting the number of test cases.
Each test case consists of two space-separated integers
�
X and
�
Y, the target for team
�
B and the current score of team
�
B respectively.
Output Format
For each test case, output how many more runs team
�
B should score to win the match.
Explanation:
Test case
1
1: The target is
200
200 runs and team
�
B has already made
50
50 runs. Thus, the team needs to make
200
−
50
=
150
200−50=150 runs more, to win the match.
Test case
2
2: The target is
100
100 runs and team
�
B has already made
99
99 runs. Thus, the team needs to make
100
−
99
=
1
100−99=1 runs more, to win the match.
Test case
3
3: The target is
130
130 runs and team
�
B has already made
97
97 runs. Thus, the team needs to make
130
−
97
=
33
130−97=33 runs more, to win the match.
Test case
4
4: The target is
53
53 runs and team
�
B has already made
51
51 runs. Thus, the team needs to make
53
−
51
=
2
53−51=2 runs more, to win the match.
Информация по комментариям в разработке