We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
importjava.io.*;importjava.util.*;publicclassSolution{publicstaticvoidmain(String[]args){/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */Scannerin=newScanner(System.in);intN=in.nextInt();//number of peopleintM=in.nextInt();//number of topicsString[]person_info=newString[N];for(inti=0;i<N;i++)person_info[i]=in.next();longteams=0;longmax_covered=0;longmatched_topics=0;for(inti=0;i<N;i++){for(intk=i+1;k<N;k++){matched_topics=0;for(intj=0;j<M;j++){if(person_info[i].charAt(j)-'0'>0||person_info[k].charAt(j)-'0'>0)matched_topics++;}if(matched_topics==max_covered)teams++;elseif(matched_topics>max_covered){max_covered=matched_topics;teams=1;}}}System.out.println(max_covered);System.out.println(teams);/*for (int i = 0; i < N; i++) { System.out.printf("%sn", person_info[i]); }*/in.close();}}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
ACM ICPC Team
You are viewing a single comment's thread. Return to all comments →