Information is present in the screenshot and below. Based on that need help in solving the code for this problem in python. The time complexity has to be as less as possible (nlogn or n at best, no n^2). Apply divide-and-conquer algorithm in the problem. Make sure all test cases return expected outputs by providing output screenshots. Provide screenshots  Hint: Apply bisection method/modules Output Format Output contains a line with two space-separated integers W_a and W_b. - W_a is the maximum matchups won by Hamiltonia - W_b is the maximum matchups won by Burrgadia. Sample Input 0 3 5 5 4 4 0 2 4 1 0 Sample Output 0 3 0 Sample Input 1 5 4 8 3 3 4 8 5 1 8 3 Sample Output 1 2 2 Sample Input 2 7 8 10 2 8 12 1 9 12 6 0 13 1 9 8 5 1 Sample Output 2 7 0 The actual code """ Solves a test case Parameters: a   : int        - number of leaders in Hamiltonia b   : int        - number of leaders in Burrgadia s_i : array-like - rap proficiencies of Hamiltonia's leaders r_j : array-like - rap proficiencies of Burrgadia's leaders Returns: win_a : int - number of wins from Hamiltonia win_b : int - number of wins from Burrgadia """ def solve(a,b,s_i,r_j):     # TODO      a,b = list(map(int,input().strip().split(" "))) s_i = [int(input()) for i in range(a)] r_j = [int(input()) for i in range(b)] win_a, win_b = solve(a,b,s_i,r_j) print(f"{win_a} {win_b}")

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Information is present in the screenshot and below. Based on that need help in solving the code for this problem in python. The time complexity has to be as less as possible (nlogn or n at best, no n^2). Apply divide-and-conquer algorithm in the problem. Make sure all test cases return expected outputs by providing output screenshots. Provide screenshots 

Hint: Apply bisection method/modules

Output Format
Output contains a line with two space-separated integers W_a and W_b.
- W_a is the maximum matchups won by Hamiltonia
W_b is the maximum matchups won by Burrgadia.

Sample Input 0
3 5
5
4
4
0
2
4
1
0

Sample Output 0
3 0

Sample Input 1
5 4
8
3
3
4
8
5
1
8
3

Sample Output 1
2 2

Sample Input 2
7 8
10
2
8
12
1
9
12
6
0
13
1
9
8
5
1

Sample Output 2
7 0

The actual code

"""
Solves a test case

Parameters:
a   : int        - number of leaders in Hamiltonia
b   : int        - number of leaders in Burrgadia
s_i : array-like - rap proficiencies of Hamiltonia's leaders
r_j : array-like - rap proficiencies of Burrgadia's leaders

Returns:
win_a : int - number of wins from Hamiltonia
win_b : int - number of wins from Burrgadia
"""
def solve(a,b,s_i,r_j):
    # TODO
    
a,b = list(map(int,input().strip().split(" ")))

s_i = [int(input()) for i in range(a)]
r_j = [int(input()) for i in range(b)]

win_a, win_b = solve(a,b,s_i,r_j)

print(f"{win_a} {win_b}")

Decisions are happening over battle. Two armies walk onto the battlefield, diametric'ly opposed, foes. They
emerge with a compromise, having opened doors that were previously closed.
They decide that their nations' fate must be addressed with diplomacy. Specifically, the sovereignty of their
nations will be decided with a rap battle between the two nations' government leaders. May the raddest
nation win.
The first nation of Hamiltonia has A leaders, each having a rap proficiency of Rį. The second nation of
Burrgadia has B leaders, each having a rap proficiency of S₁.
If one of the nations has more or fewer leaders than the other, only K rap battles will occur, where
K
min (A, B). The nation with fewer leaders can decide whom among its ranks will be matched against
each of the opposing team's leaders.
=
In a rap battle, the leader with the greater rap proficiency wins. Let us assume that two representatives are
currently matched up. Representative 1 has a rap proficiency of 5, while Representative 2 has a rap proficiency
of 6. Representative 2 will win in this case. If a tie occurs between two leaders' rap proficiencies, the winner is
the team with more total leaders, i.e., the team who did NOT choose the matchups.
Given the lineups of Hamiltonia and Burrgadia, can you determine the maximum matches each side can win,
assuming that the team with fewer leaders chooses their matchups optimally?
Input Format
Input begins with a line containing two space-separated integers: A and B, the number of leaders of
Hamiltonia and Burrgadia, respectively.
A lines follow, each containing a single integer Rį, the rap proficiency of Hamiltonia's ith leader.
B lines follow, each containing a single integer S;, the rap proficiency of Burrgadia's jth leader.
Constraints
1 ≤ A, B ≤ 2.105
A# B
0≤ Ri, Sj ≤ 10⁹
Transcribed Image Text:Decisions are happening over battle. Two armies walk onto the battlefield, diametric'ly opposed, foes. They emerge with a compromise, having opened doors that were previously closed. They decide that their nations' fate must be addressed with diplomacy. Specifically, the sovereignty of their nations will be decided with a rap battle between the two nations' government leaders. May the raddest nation win. The first nation of Hamiltonia has A leaders, each having a rap proficiency of Rį. The second nation of Burrgadia has B leaders, each having a rap proficiency of S₁. If one of the nations has more or fewer leaders than the other, only K rap battles will occur, where K min (A, B). The nation with fewer leaders can decide whom among its ranks will be matched against each of the opposing team's leaders. = In a rap battle, the leader with the greater rap proficiency wins. Let us assume that two representatives are currently matched up. Representative 1 has a rap proficiency of 5, while Representative 2 has a rap proficiency of 6. Representative 2 will win in this case. If a tie occurs between two leaders' rap proficiencies, the winner is the team with more total leaders, i.e., the team who did NOT choose the matchups. Given the lineups of Hamiltonia and Burrgadia, can you determine the maximum matches each side can win, assuming that the team with fewer leaders chooses their matchups optimally? Input Format Input begins with a line containing two space-separated integers: A and B, the number of leaders of Hamiltonia and Burrgadia, respectively. A lines follow, each containing a single integer Rį, the rap proficiency of Hamiltonia's ith leader. B lines follow, each containing a single integer S;, the rap proficiency of Burrgadia's jth leader. Constraints 1 ≤ A, B ≤ 2.105 A# B 0≤ Ri, Sj ≤ 10⁹
Expert Solution
steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Use of XOR function
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education