LEBALONS Getting WA

I am getting WA for the problem. I have absolutely no idea why, whole contest I tried this problem :frowning:
Can anyone help? Here’s my code.

Try this case:

1
9 4
1 8
2 10
2 3
5 7
5 2
1 5
3 8
2 8
4 8

Correct answer:

36.73333333

Your answer:

36.870833

Your code prints the correct answer when the colors are sorted, same input with sorted colors:

1
9 4
1 5
1 8
2 8
2 10
2 3
3 8
4 8
5 7
5 2
1 Like

Well, After that much hardship this was my stupid mistake , I sorted the color array but didn’t sorted the cost array respectively … -_- … what a fool I am! I repeatedly do this type of mistakes , Do you have any tips how to avoid this type of mistakes?

Yes , thats because then the sort algorithm doesn’t change anything of the color cost Array. and thanks BTW

Just keep practicing. With time even if you do make similar mistakes you’ll be able to catch them sooner.