Wrong answer IPCTRAIN

Could somebody help me in finding which testcase my code is failing in the que IPCTRAIN

Code Link

Why are you using sets? Sets CANNOT store duplicates. As such, your approach fails if more than 1 instructor with same properties is present. Eg-

Input
1
3 5
3 1 1000
3 1 1000
3 1 1000
Your Output
2000 (only 1 instructor added in set)
Expected Output
0

Perhaps increasing lectures in case of encountering same type of instructor can help.

1 Like

sets wont store duplicates , so just use multiset for this purpose another stl in c++ which works same as set but allows you to store duplicates.

if not you can refer to this solution , i simply used priority queue to do -
https://www.codechef.com/viewsolution/14517735

I knew the priority queue approach but wanted to try it with sets btw Thanks!! just appended and multi before set and it got a AC :slight_smile:

Multiset would be a better option Thanks btw!:slight_smile:

yes multiset is a better option to set in case of a heap if you are looking at storing duplicates

//