TORONTO KIDS COMPUTER CLUB | Tuesday Python Homework 18:30 – 22.11.22.
21449
post-template-default,single,single-post,postid-21449,single-format-standard,ajax_fade,page_not_loaded,,qode-theme-ver-7.6.2,wpb-js-composer js-comp-ver-6.10.0,vc_responsive

Tuesday Python Homework 18:30 – 22.11.22.

26 Nov Tuesday Python Homework 18:30 – 22.11.22.

Question 1:
Apple has come to hire interns from your classmates. N students got shortlisted out of which few were males and a few females. All the students have been assigned talent levels. Smaller the talent level, lesser is your chance to be selected. Apple wants to create the result list where it wants the candidates sorted according to their talent levels, but there is a catch. This time Apple wants to hire female candidates first and then male candidates.

the task is to create a list where first all female candidates are sorted in a descending order and then male candidates are sorted in a descending order.

Input Specification:
The first line contains an integer N denoting the number of students. Next, N lines contain two space-separated integers, ai and bi.
The first integer, ai will be either 1(for a male candidate) or 0(for female candidate).
The second integer, bi will be the candidate’s talent level.

Output Specification:
Output space-separated integers, which first contains the talent levels of all female candidates sorted in descending order and then the talent levels of male candidates in descending order.

Sample Input
5
0 3
1 6
0 2
0 7
1 15

Sample Output
7 3 2 15 6
No Comments

Sorry, the comment form is closed at this time.