Links to practice and competition are backwards.
I guess I had gone mad because I couldn’t think of such a simple solution. So I did this using segment trees.
O(n*log(n)*log(n))
https://www.codechef.com/viewsolution/14497188
Can anyone help me? Author solution I seem that complexity O(N*T).Here N=100000 and T=100000 according to Constraints.How it’s passed all test case.May be something i miss.Thanks in advance.
Links for all tutorials of July long challange for practice and contest seem to be swapped. Please consider correcting them .
Could someone please tell me why I’m a getting a TLE in my solution. I’ve used priority queue.
please explain how to implement priority queue here?? i am not able to understand plz tell @vijju123
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.
https://www.codechef.com/viewsolution/19193154
Solution : Great!
Comments : Extraordinary
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
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-
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?