Please does anyone have an idea on how to solve the above-mentioned problem

I've tried using the sum of the set bits and many others but all seem to be wrong

Please any hint/solution will be appreciated. Thanks.

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

1 | tourist | 3645 |

2 | Radewoosh | 3403 |

3 | LHiC | 3336 |

4 | wxhtxdy | 3329 |

5 | Benq | 3320 |

6 | Um_nik | 3301 |

7 | V--o_o--V | 3275 |

8 | mnbvmar | 3193 |

9 | yutaka1999 | 3190 |

10 | ainta | 3180 |

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

1 | Errichto | 191 |

2 | Radewoosh | 177 |

3 | rng_58 | 164 |

4 | PikMike | 162 |

5 | Vovuh | 161 |

6 | majk | 158 |

7 | 300iq | 154 |

8 | Um_nik | 151 |

9 | kostka | 149 |

10 | antontrygubO_o | 148 |

Please does anyone have an idea on how to solve the above-mentioned problem

I've tried using the sum of the set bits and many others but all seem to be wrong

Please any hint/solution will be appreciated. Thanks.

Hi all,

I tried solving the above-mentioned problem

LINK: Click me

**MY APPROACH**

*Binary search for the highest value that still keeps it in a true state*

But I seem to be getting the Wrong Answer

Please help me out. Thanks.

Hello everyone,

Since yesterday I have been reading the above stated problem but am not still able to come up with a solution, I have seen the editorial but i don't understand the proof for the algorithm.

LINK TO PROBLEM: http://usaco.org/index.php?page=viewproblem2&cpid=834

EDITORIAL: http://usaco.org/current/data/sol_sort_silver_open18.html

**PROBLEM STATEMENT**

Keeping an eye on long term career possibilities beyond the farm, Bessie the cow has started learning algorithms from various on-line coding websites. Her favorite algorithm thus far is "bubble sort". Here is Bessie's implementation, in cow-code, for sorting an array A of length N.

```
sorted = false
while (not sorted):
sorted = true
moo
for i = 0 to N-2:
if A[i+1] < A[i]:
swap A[i], A[i+1]
sorted = false
```

Apparently, the "moo" command in cow-code does nothing more than print out "moo". Strangely, Bessie seems to insist on including it at various points in her code.

Given an input array, please predict how many times "moo" will be printed by Bessie's code.

**N<=100,000, each element being an integer in the range 0…10^9. Input elements are not guaranteed to be distinct.**

Please help me find an easier to understand solution to the problem, Thanks.

Codeforces (c) Copyright 2010-2019 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Aug/18/2019 13:07:23 (f2).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|