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.

https://www.codechef.com/viewplaintext/18941549

My solution is also failing for Subtask 2 don’t know why. Though the logic is same as explained in editorial.
https://www.codechef.com/viewsolution/19193154

Could someone please tell me why I’m a getting WA
https://www.codechef.com/viewsolution/20412633

Solution : Great!
Comments : Extraordinary :smiley:

2 Likes

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-

1
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.

2 Likes

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-
https://www.codechef.com/viewsolution/25259592

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
Pypy3

Can someone help me in finding my mistake
https://www.codechef.com/viewsolution/28465312

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