The problem : www.spoj.com/problems/PRATA/
Solution: There are many solutions one can use binary search which is straight forward if you understand the concept of binary search . Use the link to find a binary search based implementation
http://spoj-solutions.blogspot.in/2014/10/prata-roti-prata.html
I used a min-heap based solution. The algorithm is to find the the cook who will next become free and assign him a prata, as simple as that.
My solution is O(p*L) which got accepted. You can find the code through following link
https://github.com/kanirudh/spoj/blob/master/prata.cpp
Comment below in case of queries.
No comments:
Post a Comment