Programming contests

50 Programming Exercise for Beginners

January 2, 2019 12:00 AM – December 31, 2019 12:00 AM

Minions

The history of the minions comes from the beginning of time. The minions started as a yellow single-celled organism and evolved through ages and served the most gru-like masters. Since these masters have been lost continuously from T-Rex to Napoleon, the minions now have nobody to serve and have fallen into deep depression.

But a minion named Kevin has a plan. With two companions on his side, he wants to search the world for the new evil leader whom their race can follow. In order to succeed, however, he has to consider thoroughly which two partners to take. It is your task to write a program for Kevin that reads the data of minions from the standard input until end-of-file, at least 2, up to 20, one per line. A line is structured as follows:

minion_name;hunger;enthusiasm;pants_size

minion_name is a unique string of up to 30 characters, with only English letters. hunger and enthusiasm are both integers from 0 to 100, while pants_size is one of „S”, „L”, „XL” and „XXL”. Data in the line are separated from each other by semicolon (;) characters.

The better companion of two minions is the one who is more enthusiastic, in case of equally enthusiastic minions, Kevin will rank them based on the lexicographical order of their names.

You have to print exactly two lines to the standard output, both of them containing the name of a minion, his hunger, and the size of his pants in the following format:

minion_name hunger (pants_size)

The best travel companion should appear in the first line, and write the second best minion in the second line.

Sample Input

  1. Bob;87;100;S
  2. Dave;43;10;L
  3. Stuart;50;30;L
  4. Jerry;40;20;XL
download as text file

Output for Sample Input

  1. Bob 87 (S)
  2. Stuart 50 (L)
download as text file

One possible solution is available in: main.c.

Acknowledgement This work was supported by the construction EFOP-3.4.3-16-2016-00021. The project was supported by the European Union, co-financed by the European Social Fund.
University of Debrecen; Faculty of Informatics; v. 03/01/2019