# MIXCOLOR: Help in test cases

I am solving MIXCOLOR but it is showing WA… Can you tell me which test cases it is failing?

Here is my implementation: link text

Your code failed for this test case I tried: `1 1 3 5`. Your code gives output 3 but the correct output is 1. It fails when a[i] + max becomes greater than a[i+1].

1 Like

Here is my approach, suppose any color has count equal to 1, for example consider the test case -

5

1 2 3 4 5

In such a case, the number of colors are 5 and each color has a count of 1, there is NO need of mixing and your output should be ZERO.
But, suppose if any color has count more than 1, for example consider the test case -

3

2 2 2

here the number of colors is 3 and only 1 type of color exists which has count=3, here you need minimum 2 mixing operations to make them distinct… so for each color which has a count > 1, you need (count-1) mixing operations to make it distinct.

You can check my code here CodeChef: Practical coding for everyone

1 Like

U need to make changes in a[i-1] not in a[i] and after that u will get write verdict.
CodeChef: Practical coding for everyone i have made changes in ur solution and it has passed all the test cases

1 Like

I know you all are doing correct but it can be done more easily:

Take all inputs in set say ‘A’

Then print answer = #of inputs - #of elements in set ‘A’

1 Like

I changed my code to a[i] == a[i - 1], it passes your test case but still fails many… please help again … CodeChef: Practical coding for everyone

pls up vote

otherwise it will fail on all the test cases in which no are reapeated more than twice.