import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
public class Test {
public static void main(String[] args) {
final String[] str = { "a-b 1:1", "a-c 2:1", "b-c 0:1" };
final Map map = new HashMap();
for (String s : str) {
final String[] temp = s.split(" ");
final String[] names = temp[0].split("-");
final String[] counts = temp[1].split(":");
for (int i = 0; i < 2; i++) {
String name = names[i];
int count = Integer.parseInt(counts[i]);
if (map.containsKey(name)) {
map.put(name, map.get(name) + count);
} else {
map.put(name, count);
}
}
}
final List teams = new LinkedList();
for (String name : map.keySet()) {
teams.add(new Team(name, map.get(name)));
}
Collections.sort(teams);
System.out.println("队伍 : 分");
for (Team t : teams) {
System.out.println(t.getName() + " : " + t.getCount());
}
}
}
class Team implements Comparable {
private String name;
private int count;
public Team(String name, int count) {
this.name = name;
this.count = count;
}
public void addCount(int count) {
this.count = this.count + count;
}
public String getName() {
return name;
}
public int getCount() {
return count;
}
public int compareTo(Team o) {
return o.getCount() - this.count;
}
}