+ 3

New Driver's License (How to do this)?

14th Oct 2021, 1:17 AM
Ctrl + Z
6 Respostas
+ 4
#this may help you and I have done in python, don't mind :) #to get myname my_name = input() #to get agent name agents = int(input()) #to get all the list names of people other_names = input() #converting all the string to lost to sort list_of_names = other_names.split() #appending myname to compare list_of_names.append(my_name) #sorting the list as question said, work is done only in alpha order. list_of_names.sort() #getting the index of our name in the list... index = list_of_names.index(my_name) + 1 #if the agents r more than index of our name, work will done soon. #because if 5 agents r thr and thr are only 4 peoples, then my task will get sooner if agents >= index: result = 20 #if that's not the case start decounting the value with index and agent and finallu print the value else: time = index - agents result = 20 + time * 20 #print the result finally... print(result)
14th Oct 2021, 1:19 AM
GURURAJ KL
+ 2
Thank you ☺️
14th Oct 2021, 1:20 AM
Ctrl + Z
+ 1
Brian As in the question they r asking us to sort the list of names
14th Oct 2021, 8:12 AM
GURURAJ KL
0
GURURAJ KL There is no requirement that says you must sort the names. The task is to determine how long it will take. You can efficiently determine the correct answer without sorting. A simple count of names less than or equal to your name gives the number to scale for the wait time.
14th Oct 2021, 8:42 AM
Brian
0
myname = input() num_agents = int(input()) other_names = list(input().split()) other_names.append(myname) other_names.sort() ind_myname = other_names.index(myname)+1 print('20' if ind_myname <=num_agents else (ind_myname-num_agents)*20+20)
25th Nov 2021, 10:31 PM
Mas'ud Saleh
- 1
There is no need to sort. Just loop through the given names and count how many names are less than or equal to yours. GURURAJ KL's technique would give a wrong answer if there is already someone in line with the same name as you.
14th Oct 2021, 7:48 AM
Brian