Hello Codeforces community! I recently took part in the July 2015 long challenge on www.codechef.com . There was a problem called Masterchef( Problem code: MCHEF). I used a multiset as a priority queue to calculate the minimum cost for each dish. In the author's solution, they used a set instead of a multiset. The complexities are the same but my solution TLEs for the second subtask. Could someone please help me out here?
This is my solution: https://www.codechef.com/viewsolution/7352429 This is the editorial: http://discuss.codechef.com/questions/71856/mchef-editorial
Thanks in advance.
You are using long long everywhere instead of int which makes your solution very slower as compared to other solutions , also it would be good if you use priority_queue instead of set as they are much faster.
I used a multiset because there are duplicate values which as far as I understand are not accomodated by priority queues.
Changing long long to int worked slightly but not well enough.
I've solved it using multiset link
so multiset might not be the reason for TLE
I can't think of any other reason. Could it be that I'm allocating too much memory during by testcases for loop?
ignore.
didn't read the complete editorial.
I also solved it by multiset. My solution is here. And also I used long long without getting TLE.
Also, I've written two solutions one of which is giving me a wrong answer with the only difference being that I declared the array outside. What is the difference?