WA in spoj PRATA

Can anybody tell me where I have made mistake?

Problem

My solution

p.s. How can I use priority queue in it?

You can have a look at My solution using priority queue. Also my binary search approach is here.

Thank you for your reply. I saw your binary search approach. My approach also looks same. You generated the amount of prata using a formula. I used an iterative approach. But it gives the same thing. Where have I made mistake?

What is the formula used inside the check() method to calculate the pratas ?

1 Like