IPCTRAIN - Editorial

Need help!
My solution is passing Subtask 1 completely but it fails Subtask 2 completely.
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!

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ā

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
for(Teacher t: remaining) {

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

Nice approach

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?

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