GUPTA MECHANICAL

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

Sunday 8 May 2022

Four Arrays CodeChef Solution | CodeChef Problem Solution 2022

You have been given an integer K and four arrays ABC, and D with sizes SASBSC and SD respectively.

Follow the given steps:

  • Pick four indices xyz, and w from arrays ABC, and D respectively. Note that (1xSA)(1ySB)(1zSC) and (1wSD).
  • There are in total SA×SB×SC×SD ways to do the above step. For each way, write down the value of (Ax+By)×(Cz+Dw) on a board.
  • Sort all the numbers written on the board in non-decreasing order.
Solution Click Below:-  CLICK HERE

Find the Kth element written on the board.

Input Format

  • First line contains five integers SASBSCSD and K.

  • The second line contains SA space-separated integers A1,A2,...,ASA denoting the array A.
  • The third line contains SB space-separated integers B1,B2,...,BSB denoting the array B.
  • The fourth line contains SC space-separated integers C1,C2,...,CSC denoting the array C.
  • The fifth line contains SD space-separated integers D1,D2,...,DSD denoting the array D.

Output Format

For each test case, output the required number in a single line .

Constraints

  • 1SA,SB,SC,SD3104
  • 1KSA×SB×SC×SD
  • 0Ai,Bi,Ci,Di105

Sample Input 1 

2 1 3 2 10
2 3
2
1 1 2
3 1

Sample Output 1 

20

Explanation

After sorting the numbers on the board are in the following order {8,8,10,10,12,15,16,16,20,20,20,25}. So, the 10th number is 20.

Join Now for Solution:- 

No comments:

Post a Comment