GUPTA MECHANICAL

IN THIS WEBSITE I CAN TELL ALL ABOUT TECH. TIPS AND TRICKS APP REVIEWS AND UNBOXINGS ALSO TECH. NEWS .............

Wednesday 3 August 2022

[Solution] Nearest Court CodeChef Solution



Problem

Chef and Chefina are at positions X and Y on a number line.

They both love badminton.

It is known that badminton courts are located at every integer point.

They want to find a court such that the maximum distance travelled by either of them is minimized.

Formally, suppose they choose the badminton court at position Z. You need to find the minimum value of \max(|X-Z|, |Y-Z|) across all possible choices of Z. Here, |X| denotes absolute value of X.

Report this minimum value.

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.

Output Format

For each test case, output the minimum possible value of \max(|X-Z|, |Y-Z|).

No comments:

Post a Comment