## COCI '14 Contest 4 #2 Pšenica

View as PDF

Points: 12 (partial)
Time limit: 0.6s
Memory limit: 32M

Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

Our heroes, Mirko and Slavko, plant Christmas wheat every year on Saint Lucy's Day. It is well known that stalks of wheat grow at different speeds so, after a certain time, the wheat becomes quite messy. The guys are determined to solve this problem by playing the following game:

• When it's Mirko's turn, he chooses a stalk of wheat with the minimal height and prolongs its height so it's of the same height as the first stalk longer than it.
• When it's Slavko's turn, he chooses a stalk of wheat with the maximal height and cuts it to be of the same height as the first stalk shorter than it.
• The game lasts while there are at least three stalks of different heights and the loser is the player who can't make his move.

For given heights of all stalks of wheat and the assumption that Mirko is the one starting the game, determine the winner of the game and the height of the shortest and longest stalk when the game is finished.

#### Input

The first line of input contains the integer , the number of wheat stalks.

The second line of input contains space separated integers that denote the heights of individual wheat stalks. The height of each stalk will be less than or equal to .

#### Output

The first line of output must contain the word Mirko if Mirko is the winner of the game, or Slavko if Slavko is the winner of the game.

The second line of output must contain the height of the shortest and longest stalk when the game is finished.

#### Scoring

In test cases worth 50% of total points, it will hold .

In test cases worth 80% of total points, it will hold .

#### Sample Input 1

3
3 3 3

#### Sample Output 1

Slavko
3 3

#### Explanation for Sample Output 1

Mirko can't make his move because there are no three stalks of different heights. Therefore, Slavko is the winner.

#### Sample Input 2

4
3 1 2 1

#### Sample Output 2

Slavko
1 2

#### Sample Input 3

7
2 1 3 3 5 4 1

#### Sample Output 3

Slavko
2 3

• commented on Aug. 15, 2019, 2:40 p.m.

I did it! After 2 sleepless nights I have finally managed to solve it

• commented on July 27, 2018, 7:59 p.m. edit 2

Why am i getting this message?https://postimg.cc/image/foqgh7v5z/ Is TreeMap not allowed?

• commented on July 27, 2018, 8:22 p.m. edited

I believe that message appears when you try to submit a Java program with 2 public classes. Just make one of them not public and things should be okay...

• commented on July 27, 2018, 8:49 p.m.

I just tested a bit and I think that Pšenica(probably the š) being in the public class name causes this to happen.

• commented on July 28, 2018, 11:38 p.m.

Issue is resolved, you can now use all valid Java classnames.

• commented on Aug. 10, 2017, 9:33 p.m.

Does "first stalk longer than it" in the problem statement mean the leftmost stalk longer than it or a shortest stalk longer than it?

• commented on July 22, 2018, 9:41 p.m.

Yes, it means the shortest stalk longer than it.