143. Zoom Meeting

Codeforces
IDCF10269143
Time1000ms
Memory256MB
Difficulty
English · Original
Formal · Original
You're attending an international Zoom call during the Coronavirus quarantine, where the attendees represent many different countries. The zoom call is really long, and to pass the time, you tally how many people are from each country. Given the list of people and their countries, print the countries, and how many meeting attendees are from each country. Sort the countries first by their number of attendees, and if two countries have an equal number of attendees, sort them alphabetically by the name of the country. The first line of input contains a single positive integer $n$: the number of meeting attendees. The next $n$ lines each contain a single country name $c$. If there are less than five lines of input, output $n$ lines: each country, and it's number of meeting attendees, separated by a space. Otherwise, output 5 lines: each of the top 5 countries using the sorting method described above, and it's number of meeting attendees, separated by a space. ## Input The first line of input contains a single positive integer $n$: the number of meeting attendees.The next $n$ lines each contain a single country name $c$. ## Output If there are less than five lines of input, output $n$ lines: each country, and it's number of meeting attendees, separated by a space.Otherwise, output 5 lines: each of the top 5 countries using the sorting method described above, and it's number of meeting attendees, separated by a space. [samples]
**Definitions** Let $ n \in \mathbb{Z}^+ $ be the number of attendees. Let $ C = (c_1, c_2, \dots, c_n) $ be a sequence of country names, where each $ c_i \in \mathcal{C} $ and $ \mathcal{C} $ is the set of all possible country names. Define the frequency function $ f: \mathcal{C} \to \mathbb{Z}^+ $ such that $ f(x) = |\{ i \mid c_i = x \}| $. Let $ S = \{ (x, f(x)) \mid x \in \mathcal{C}, f(x) > 0 \} $ be the set of country-frequency pairs. **Constraints** 1. $ 1 \leq n \leq \infty $ (practically bounded by input size) 2. Each $ c_i $ is a non-empty string representing a country name. **Objective** Sort $ S $ by: - Primary: descending order of frequency $ f(x) $ - Secondary: ascending alphabetical order of country name $ x $ (for ties in frequency) If $ n < 5 $, output all $ |S| $ pairs in sorted order. Otherwise, output the top 5 pairs from the sorted $ S $. Each output line is of the form: $ x \; f(x) $, where $ x $ is the country name and $ f(x) $ is its count.
API Response (JSON)
{
  "problem": {
    "name": "143. Zoom Meeting",
    "description": {
      "content": "You're attending an international Zoom call during the Coronavirus quarantine, where the attendees represent many different countries. The zoom call is really long, and to pass the time, you tally how",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF10269143"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "You're attending an international Zoom call during the Coronavirus quarantine, where the attendees represent many different countries. The zoom call is really long, and to pass the time, you tally how...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ n \\in \\mathbb{Z}^+ $ be the number of attendees.  \nLet $ C = (c_1, c_2, \\dots, c_n) $ be a sequence of country names, where each $ c_i \\in \\mathcal{C} $ and $ \\mathcal{C} $ is ...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments