Dividing array - Greedy

Problem: https://online.codingblocks.com/app/player/99366/content/98748/5030/code-challenge
My Code : https://ide.codingblocks.com/s/240950
Second test case is giving TLE, can’t find a better solution with greedy approach , any changes or suggestions?