An unnamed international contest just finished. There were exactly four contestants from each of the participating countries.
During the contest each of the contestants achieved a non-negative integer score (the higher, the better).
The contestants were sorted according to their scores and the first part of the overall results (i.e., the best few contestants)
was announced during the final ceremony.
The organizers of the contest decided not to publish the remaining, lower part of the results.
In the Countries Ranklist the countries are ordered (in decreasing order) by the total score of their four contestants.
If two or more countries have the same score, they are tied for the best place from the corresponding interval,
and the places of the lower ranked countries remain unaffected. For example, if the total scores of countries A, B, C and D
are 100, 90, 90 and 80, respectively, then B and C are tied for second place, and D is fourth. For further
clarification, see examples 2 and 4.
A String[] knownResults will represent the published part of the results, with each of the elements describing one of the announced contestants.
The elements have the form "COUNTRY CONTESTANT SCORE",
where COUNTRY is the name of the country, CONTESTANT is the name of the contestant
and SCORE is his score.
Your task will be to compute the best and the worst possible placement in the Countries Ranklist
for each of the participating countries.
You shall assume that from each country at least one contestant was announced and that
all contestants not in the available part of the results scored strictly less
than the worst contestant in the available part of rankings. (For example, if the worst announced
contestant scored 47 points, then each of the not announced contestants from each of the participating
countries could have scored at most 46 points.)
You are to return a String[] with one element for each country.
The form of each element must be "COUNTRY BEST WORST", where COUNTRY is the name of the country,
BEST and WORST are the best and the worst position this country could possibly have in the Countries Ranklist.
Order this list so that the country names are given in alphabetical order. Note that country names are case sensitive, and that in alphabetical order all uppercase letters come before lowercase letters. The numbers BEST and WORST mustn't contain leading zeroes.
|