z-pesak
Mr. Little Z likes to play chess. However, one day he got bored with ordinary chess and decided to make a new game to play on a chess board.
After a long time, Mr. Little Z has finally made a game and he wants you to play with him.
The rules are as follows: The chess board, where the game is played, is infinitely large. In the game you use only one man - a pawn. The game lasts N+1 seconds. At the begging the pawn is standing at the position (0, 0) for one second, and after that Mr. Little Z says where the pawn has to go every second, and that is:
'Gore' - If the pawn has to move up one position
'Dole' - If the pawn has to move down one position
'Levo' - If the pawn has to move left one position
'Desno' - If the pawn has to move right one position
'Ostajem na ovom polju' - If the pawn stays at the same position for one more second
After that you need to determine which position the pawn spent the greatest amount of time on. It may be possible to have more than one position that answers this question, but Mr. Little Z only wants you to tell him how long the pawn spent at the position.
5
Levo
Gore
Levo
Desno
DesnoOutput:
2Explanation:
On interval 0..1 the pawn is at the position (0, 0), after that Mr. Little Z is giving the commands:
On interval 1..2 the pawn is at the position (-1, 0)
On interval 2..3 the pawn is at the position (-1, 1)
On interval 3..4 the pawn is at the position (-2, 1)
On interval 4..5 the pawn is at the position (-1, 1)
On interval 5..6 the pawn is at the position (0, 1), and the game is over.
And the pawn spent 2 seconds at the position (-1, 1)
Submit solution
Coming laterThe grading service will be connected in a later migration step. You can inspect the task and your previous results now.