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 : CodeChef: Practical coding for everyone
Code Link : CQulix - Online C++0x Compiler & Debugging Tool - Ideone.com

Thanks in advance