Dividing array problem greedy

https://ide.codingblocks.com/s/237903 why this is giving tle and wrong anser??