GUPTA MECHANICAL

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

Sunday 17 July 2022

[Solution] Maximum Median Matching CodeChef Solution




boys and N girls attend a dance class, where N is odd. For today's practice session, they need to form N boy-girl pairs.

The i-th boy has a happiness value of Ai and the i-th girl has a happiness value of Bi. A pair consisting of the i-th boy and the j-th girl has a happiness value of Ai+Bj.

Let the happiness values of the N pairs be C1,C2,,CN. The dance instructor would like it if many of the pairs have a high happiness value, and passes the task to you — find the maximum possible value of the median of C, if the boy-girl pairs are chosen optimally.

Note: The median of a odd-sized list of integers is the middle number when they are sorted. For example, the median of [1] is 1, the median of [1,5,2] is 2, and the

Solution Click Below:-  👉CLICK HERE👈
👇👇👇👇👇

 median of [30,5,5,56,3] is 5.

Input Format

  • The first line of input will contain a single integer T, denoting the number of test cases.

  • Each test case consists of three lines of input.
    • The first line of each test case contains a single integer N.
    • The second line of each test case contains N space-separated integers A1,A2,,AN — the happiness values of the boys.
    • The third line of each test case contains N space-separated integers B1,B2,,BN — the happiness values of the girls.

Output Format

For each test case, output on a new line the maximum possible median happiness of the N pairs.

Constraints

  • 1T3104
  • 1N<3105
  • N is odd
  • 1Ai,Bi109 for each valid i
  • The

No comments:

Post a Comment