you give array task tasksi actuali minimumiactuali actual energy spend finish ith taskminimumi minimum energy require begin ith taskFor example task 10 12 current energy 11 start task however current energy 13 complete task energy 3 finishing itYou finish task order likereturn minimum initial energy need finish task Example 1input task 122448output 8explanationstarte 8 energy finish task follow order 3rd task now energy 8 4 4 2nd task now energy 4 2 2 1st task now energy 2 1 1notice leftover energy start 7 energy work 3rd taskexample 2input task 13241011101289output 32explanationstarting 32 energy finish task follow order 1st task now energy 32 1 31 2nd task now energy 31 2 29 3rd task now energy 29 10 19 4th task now energy 19 10 9 5th task now energy 9 8 1example 3input task 172839410511612output 27explanationstarting 27 energy finish task follow order 5th task now energy 27 5 22 2nd task now energy 22 2 20 3rd task now energy 20 3 17 1st task now energy 17 1 16 4th task now energy 16 4 12 6th task now energy 12 6 6 Constraints1 taskslength 1051 actuali minimumi 104