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}")
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
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
""" Parameters: Returns: s_i = [int(input()) for i in range(a)] 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⁹](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fef7c41bc-9ec8-4b0d-8392-fba4e5be0a35%2Fdeb54b8d-cfca-401a-9048-663407fa6cab%2Fwii1zrm_processed.png&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Step by step
Solved in 3 steps
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)