@lord_ozb:
You have used a double loop here which caused the time to exceed the limit.
for(int i = 0; i < d; i++){
int x = -1;
int max = Integer.MIN_VALUE;
for(int j = 0; j <= i; j++){
if(queue[j].size() != 0){
Trainer temp = queue[j].peek();
if(temp.sad > max){
max = temp.sad;
x = j;
If I solve the above question using heaps as stated, then on popping out the trainer which doesn’t have any lecture remaining and at the very same time maintaining the sort would require the complexity O(n).
On the other hand if we just extract him from the heap and heapify using time complexity O(lg n) would disturb the sort. How do i proceed?
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.
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.
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.