Language 1 def main(): 2 STEN 3 Python (3.8.1) 4 n = int(input()) a=input().split("") b=input().split("") for i in range(n):

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
Please code this in Python according to the function given below.
Language
1 def main():
HN 3 J
2
For
cooSOS
8
13
Python (3.8.1)
n = int(input())
a = input().split("")
b=input().split("")
for i in range(n):
a[i] = int(a[i])
b[i] = int(b[i])
print (solution (a, b, n))
def solution (vote, age, n):
#write your code here
return 0;
15 main()
I
Transcribed Image Text:Language 1 def main(): HN 3 J 2 For cooSOS 8 13 Python (3.8.1) n = int(input()) a = input().split("") b=input().split("") for i in range(n): a[i] = int(a[i]) b[i] = int(b[i]) print (solution (a, b, n)) def solution (vote, age, n): #write your code here return 0; 15 main() I
Elections are conducted in a town that has a population of N.
All the people of the town cast votes for the various candidates in town.
The people of the town realized later that the votes of only the voter with 18 and above years of age will be considered.
Find the candidate who is the winner, if only the votes of age group 18 and above are considered.
If the winner cannot be decided or there is a tie, print -1.
Note
You are given an array vote[] which represents the candidate to whom the vote is given and another array age[] which represents the age of that particular voter.
There will be multiple test cases running so the Input and Output should match exactly as provided.
The base Output variable result is set to a default value of -404 which can be modified. Additionally, you can add or remove these output variables.
Input Format
The first line contains N. denoting the size of the array.
The second line contains an array vote[] which represents the candidate to whom the vote is given.
The third line contains an array age[] which represents the age of that particular voter.
Sample Input
10
- denotes N
1123412231 -- denotes vote[]
24 13 35 15 50 16 20 18 25 64
Constraints
1 <= N <= 106.
1<= vote[i]<= 109.
1<= age[i] <= 150.
denotes age[]
Output Format
The output should be the candidate who is the winner if only the votes of age group 18 and above are considered.
Sample Output
2
Transcribed Image Text:Elections are conducted in a town that has a population of N. All the people of the town cast votes for the various candidates in town. The people of the town realized later that the votes of only the voter with 18 and above years of age will be considered. Find the candidate who is the winner, if only the votes of age group 18 and above are considered. If the winner cannot be decided or there is a tie, print -1. Note You are given an array vote[] which represents the candidate to whom the vote is given and another array age[] which represents the age of that particular voter. There will be multiple test cases running so the Input and Output should match exactly as provided. The base Output variable result is set to a default value of -404 which can be modified. Additionally, you can add or remove these output variables. Input Format The first line contains N. denoting the size of the array. The second line contains an array vote[] which represents the candidate to whom the vote is given. The third line contains an array age[] which represents the age of that particular voter. Sample Input 10 - denotes N 1123412231 -- denotes vote[] 24 13 35 15 50 16 20 18 25 64 Constraints 1 <= N <= 106. 1<= vote[i]<= 109. 1<= age[i] <= 150. denotes age[] Output Format The output should be the candidate who is the winner if only the votes of age group 18 and above are considered. Sample Output 2
Expert Solution
steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY