Dividing array problem greedy


why this is giving tle??