Created
December 22, 2015 01:59
-
-
Save peter279k/932bc7a212fdfe9b986c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.*; | |
public class main{ | |
public static void main(String[] args) { | |
Scanner input = new Scanner(System.in); | |
int teams = input.nextInt(); | |
ArrayList<String> lists = new ArrayList<String>(); | |
ArrayList<String> res_list = new ArrayList<String>(); | |
while(input.hasNext()) { | |
String tmp = ""; | |
tmp = input.nextLine(); | |
lists.add(tmp); | |
} | |
for(int i=0;i<lists.size();i++) { | |
String []temp = lists.get(i).split(" "); | |
if(temp.length != 0) | |
res_list.add(temp[0]); | |
} | |
Collections.sort(res_list); | |
int count = 0; | |
for(int i=1;i<res_list.size();i++) { | |
if(i != res_list.size()-1) { | |
if(!res_list.get(i).equals(res_list.get(i+1))) { | |
count += 1; | |
System.out.println(res_list.get(i) + " " + count); | |
count = 0; | |
} | |
else { | |
count += 1; | |
} | |
} | |
else { | |
count += 1; | |
System.out.println(res_list.get(i) + " " + count); | |
count = 0; | |
} | |
} | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment