IPCTRAIN - Editorial

Need help!
My solution is passing Subtask 1 completely but it fails Subtask 2 completely.
Can anyone please help me figure it out where am i doing wrong?
Here is my link to solution.


My solution is also failing for Subtask 2 don’t know why. Though the logic is same as explained in editorial.

Could someone please tell me why I’m a getting WA

Solution : Great!
Comments : Extraordinary :smiley:


Lol XD. It just came into my mind when i read “A trainer who comes to the camp stays there till end of camp” :stuck_out_tongue:

use c++ Priority Queue

Your code into infinite loop for cases like this-

3 6
2 2 300
1 1 1000
2 2 300
long sadness = 0;
for(Teacher t: remaining) {
	sadness += t.lectures*t.sadness;

Declare t.sadness as long instead of int or use type casting as sadness+=1LL * t.lectures * t.sadness; - because product of 2 int is stored in the int type and then the overflowed result is stored in sadness.


In the explanation, it is not explained what to do if the condition is to assign to non top professor(sadness) then how do I avoid searching for another professor(sadness)? Linear search is causing LTE for 2nd subtask. I would appreciate response.

Can you please explain your solution.Why you did AND of both the children…

I’m getting only 40 points by my approach, by using heap sort and exactly the same logic written in explanation. Can anyone help me optimize my rest of the code to overcome TLE?
Here’s the link to my solution-

This costed me a good rating up, in August Long :dizzy_face::dizzy_face:

Nice approach :100::100:

what’s the logic behind the segment tree solution?

Same code is accepted in Python 3.6 but got TLE in pypy3. Why is that?

Python 3.6

Can someone help me in finding my mistake

here is the link to my code can anyone tell where iam getting SIGABRT error
thank you