Q1 we can possibly solve by sorting, max dp table, plus two pointers.

Sort (arr1[i], arr2[i]) by arr1[i]. Then loop the sorted, create two dp tables - new indices (not original indices in arr2, new indices in the sroted) of max arr2 encountered 0 to i, and indices of 2nd max.

Then two pointers approach to find pairs sorted[l][0] + sorted[r][0] <= threshold, if dp_max[r] != l, sorted[l][1] + sorted[dp_max[r]][1] is a candiate answer. If l is the max, combine it with the the 2nd max (actually it should be the final answer I think).

3rd one is DP + Partitioning problem and is easiest one

Q2. Just loop through all values of j and find max element to left of j (call it a) and right of j (call it b). Then calculate a + arr[j]r +br^2. Take maximum