This is a simple sorting problem.

One thing you can notice here that there is no difference between $C_i = M$ and $C_i > M$. You can replace $C_i > M$ to $C_i = M$. Then it’s pretty easy to solve. You can notice that the student with the larger number of coins leaves the queue first.

So, you have to sort the array in decreasing order of their coins & you will get your desired result.

Contributors

Statistics

76% Solution Ratio
ivanbrEarliest, Feb '21
steinumFastest, 0.0s
steinumLightest, 9.1 kB
shreasShortest, 393B
Toph uses cookies. By continuing you agree to our Cookie Policy.