Recent actions

can anybody please help how should reduce the last loop of O(n^2) to work for testcase 4 my submission-115124459

Let dp[l][r] be the sum of ai*bi ( i is between l and r) when we reverse subsegment [l,r].Sum of ai*bi(i is between l+1 and r-1) when we reverse subsegment [l,r] is same when we reverse subsegment [l+1,r-1]. Then dp[l][r]=a[l]*b[r]+a[r]*b[l]+dp[l+1][r-1]; Pref[i] is sum of ai*bi(i is between 1 and i),suff[i] is sum of ai*bi(i is between i and n). Than,we check if we reverse subsegment [l,r] than result is : pref[i-1]+dp[l][r]+suff[r+1]; Maximum of all of these results is our final answer.

Can u please explain the logic behind the DP solution?

The loop that's looping on the universities should start with the lowest possible greater or equal to K, I mean when K = 4 you shouldn't iterate over teams that has number of people less than K, unless if you do iterate over them it would be O(N^2) a time limit for sure.

Can anyone tell me why I'm getting TLE in the 8th test case in Problem C.

Here is my code:-

My code

Created or updated the text
Created or updated the text
Created or updated the text
Created or updated the text
Created or updated the text
Created or updated the text
Created or updated the text
Created or updated the text
Created or updated the text
Created or updated the text
Created or updated the text
Created or updated the text
Created or updated the text
Created or updated the text
Created or updated the text
Created or updated the text
Created or updated the text
Created or updated the text
Created or updated the text
Created or updated the text
Created or updated the text
Created or updated the text
Created or updated the text
Created or updated the text
Created or updated the text
Created or updated the text
Created or updated the text
Created or updated the text
Created or updated the text
Created or updated the text
Created or updated the text
Created or updated the text
Created or updated the text
Created or updated the text
Created or updated the text
Created or updated the text
Created or updated the text
Created or updated the text
Created or updated the text
Created or updated the text
Created or updated the text
Created or updated the text
Created or updated the text
Created or updated the text
Created or updated the text
Created or updated the text
Created or updated the text
Created or updated the text
Created or updated the text
Created or updated the text
Created or updated the text
Created or updated the text
Created or updated the text
Created or updated the text
Created or updated the text
Created or updated the text
Created or updated the text
Created or updated the text
Created or updated the text
Created or updated the text
Created or updated the text
Created or updated the text
Created or updated the text
Created or updated the text
Created or updated the text
Created or updated the text
Created or updated the text
Created or updated the text
Created or updated the text
Created or updated the text
Created or updated the text
Created or updated the text
Created or updated the text
Created or updated the text
Created or updated the text
Created or updated the text
Created or updated the text
Created or updated the text
Created or updated the text
Created or updated the text
Created or updated the text
Created or updated the text
Created or updated the text
Created or updated the text
Created or updated the text
Created or updated the text
Created or updated the text
Created or updated the text
Created or updated the text
Created or updated the text
Created or updated the text
Created or updated the text
Created or updated the text
Created or updated the text
Created or updated the text