Dividing arrays from Greedy

Here’s my code for the problem. I think the algorithm is correct and it’s giving correct output for the sample case also but it gives WA on submission.