Problem with INOI 2019 Problem 1 : Processor Scheduling

So I’m having a problem solving the 1st DP problem of INOI 2019 : Processor Scheduling
Even after implementing an Iterative DP approach for the problem , it gives TLE. I know I’m missing out on some silly bug. Can anyone help me out ?

Problem Link :
Code Link :

Thanks in advance