Question: Two stations A and B are connected to a network. Both stations have N number of addresses each. Each address is a posititve integer. The
Two stations A and B are connected to a network. Both stations have N number of addresses each. Each address is a posititve integer. The network pings the first address X of station A followed by next largest address Y from station B where the X The first combination is
Next, again and are picked. Now, as thus, is picked from A As the path cannot end with an address from A is also picked from B as The next combination is Next, is picked from A The next greater element in B is Thus, is also picked from B as As there are no other addresses left to takecombination Similarly, for all the addresses, the combinations are to be found.
Let there be Z combinations formed. Find the sum of all the addresses in each combination, thus, Z sums are calculated.
Write a program to find out the maximum Max and minimum Min sums. Max is the maximum sum of all the elements of combinations and Min is the minimum sum of elements of combinations
Read the input from STDIN standard input and write the output to STDOUT standard output Do not print any arbitrary strings while reading the input or printing the output as those contribute to STDOUT
CONstraints:
N
INPUT Format:
FIRST line of input contains N the total number of address values of Station A and Station B
SECond line of input contains N integers, which are the address values of Station A separated by a single white space.
THIRD line of input contains N integers, which are the address values of Station B separated by a single white space.
OUTPUT
tge iutput contains Max and Min seperated by single space
Sample input
Sample Output
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
