Limits
1s, 512 MB

As all people know ICPC can be very dull sometimes for people other than contestants. Jodu, Modu, and Kodu visit the contest area and watch area. They are having fun. But after some time they became bored because contestants take so much time solving exceptionally hard problems. So they come up and started playing a game.

The game goes as follows,

**Jodu**and**Modu**will play against each other.There will be an empty list with

**max capacity**$\bf{k}$.There will be $\bf{n}$

**rounds.**

In each round:

Jodu guesses a number $\bf{J}$

Modu guesses a number $\bf{M}$

if $\bf{M}$ is smaller than $\bf{J}$:

$\bf{M}$ is added to

**Modu's score**.Jodu will have to add the last element of the list to his score if it is smaller than $\bf{J}$.

After adding an element it must be removed.

Jodu will have to do this until the list is empty or he cannot add any more.

If the list is not full, then $\bf{J}$ is added to the last of the list.

else:

$\bf{J}$ is added to

**Jodu's score**.Modu will have to add the last element of the list to his score if it is smaller than $\bf{M}$.

After adding an element it must be removed.

Jodu will have to do this until the list is empty or he cannot add any more.

If the list is not full, then $\bf{M}$ is added to the last of the list.

Then the round ends.**The one having the more score will be in the lead.**

Kodu have to track who is in the lead.

They have been playing for a long time. Keeping track manually Kodu got bored and started making mistakes.

Kodu has asked you to write him a program that will keep track of **each round’s leading player**, given $\bf{J}$ and $\bf{M}$ of each round.

The first line will be an integer $\bf{T}$ indicating the number of test cases. Every test case starts with Two integers $\bf{n}$and $\bf{k}$ denoting the **number of rounds** they are playing and **the maximum capacity**. The following $\bf{n}$ **lines** will contain two integers $\bf{J}$ and $\bf{M}$ separated by spaces.

$1 \le T \le 10^3$

$1 \le n, k \le 10^5$

$1 \le J, M \le 10^7$

For every test case, first print a line in the format “**Case X:**” where **$X$** is the number of test cases starting from **$1$**. Next, You have to output $\bf{n}$ **lines**. In the next n lines, you have to print the $\bf{i^{th}}$ round’s leading player name “**Jodu**“, “**Modu**“ or “**Draw**“, if both players’ scores are same.

Input | Output |
---|---|

1 4 3 2 3 3 2 4 6 2 5 | Case 1: Jodu Draw Modu Draw |

Initially, After 1st round, After 2nd round, After 3rd round, After 4th round, |

Input | Output |
---|---|

1 4 3 1000 2000 2048 1024 48 2928 1 100000 | Case 1: Jodu Jodu Modu Modu |

Login to submit.

70%
Solution Ratio

steinumEarliest,

steinumFastest, 0.1s

shafin1196Lightest, 4.9 MB

steinumShortest, 735B

Toph uses cookies. By continuing you agree to our Cookie Policy.