TORONTO KIDS COMPUTER CLUB | PMCA Sunday 10:00 Practice -02.14
post-template-default,single,single-post,postid-19059,single-format-standard,ajax_fade,page_not_loaded,,no_animation_on_touch,qode-theme-ver-7.6.2,wpb-js-composer js-comp-ver-6.10.0,vc_responsive

PMCA Sunday 10:00 Practice -02.14

17 Feb PMCA Sunday 10:00 Practice -02.14

Question 1:
Winnie is feeling generous today, so she decided to adopt all the children in an orphanage. There are N orphanages, numbered from 1 to N, that she can choose from. Each orphanage has M children. Each children has a cuteness value ranging from 1 to 10. Winnie cannot handle children that are too cute, or children that are too ugly. Because of this, Winnie wants to choose the orphanage that has the least number of children with a cuteness value of 1 or 10. Can you help Winnie find this orphanage?

Input Specification
The first line of input will contains two integers N, M (1≤N, M≤1000), the number of orphanages and the number of children in each orphanage.

The next N lines will each contain M integers, representing the cuteness values of each children. Line i will represents from the children from orphanage i. The cuteness values are between 1 and 10, inclusive.

Output Specification
Output the index of orphanage with the least number of children with a cuteness value of 1 or 10. If multiple orphanages exists, output the one with the smallest index.

Sample Input
3 3
2 1 8
4 10 9
3 6 4

Sample Output

Explanation For Sample
The third orphanage has no children with a cuteness value of 1 or 10, while the first and second orphanages both have one children.

No Comments

Sorry, the comment form is closed at this time.