T(n) = 2*T(n/2) + n*log(n)

I tried to solve it using master method but it doesn't seem to fit any of the three cases.

Am I correct.?

# | User | Rating |
---|---|---|

1 | tourist | 3533 |

2 | Um_nik | 3459 |

3 | maroonrk | 3394 |

4 | ksun48 | 3384 |

5 | ecnerwala | 3347 |

6 | Benq | 3301 |

7 | boboniu | 3300 |

8 | Petr | 3293 |

9 | Radewoosh | 3288 |

10 | TLE | 3223 |

# | User | Contrib. |
---|---|---|

1 | Errichto | 207 |

2 | Monogon | 197 |

3 | SecondThread | 191 |

4 | pikmike | 187 |

5 | antontrygubO_o | 186 |

6 | vovuh | 185 |

7 | Um_nik | 183 |

8 | Ashishgup | 182 |

9 | Radewoosh | 169 |

10 | pashka | 168 |

I tried to solve it using master method but it doesn't seem to fit any of the three cases.

Am I correct.?

Here the program for 8 - queen puzzle.

But it is not working.

Plz tell what is the problem.

Here I tried to run it:

Earlier there was no 'x' in wikipedia I added 'x' there...

Am I correct and still it is not working.

PS: I don't know pascal, so plz don't get me on this. :)

when will it start?

India time and Moscow time.

Why I m getting "that bug message of cockroach or smthing...saying your bugs are mine" when i try to open blog of happy new year (1040)...

.. for other blogs it is okay...

and when I m not login then also okay........@admin plz check.

anywhere in the array (at the beginning, between any two existing marbles, or at the end). Help Mirko find the smallest number of marbles he must insert into the sequence before he could make all of the marbles vanish

Input

The first line of input contains two integers N (1 ≤ N ≤ 100) and K (2 ≤ K ≤5) - the number of marbles in the initial sequence and the minimal number of consecutive marbles of the same color he could wish to vanish. The next line contains exactly N integers between 1 and 100 (inclusive),separated by one space. Those numbers represent colors of marbles in the sequence Mirko found.

Output

The output should contain only one line with a single integer number - the minimal number of marbles Mirko has to insert to achive the desired effect.

Example

Input:

2 5

1 1

Output:

3

Input

10 4

3 3 3 3 2 3 1 1 1 3

Output:

4

HOW TO SOLVE THIS PROBLEM?

Codeforces (c) Copyright 2010-2020 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Oct/01/2020 19:33:20 (i2).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|