MIXCOLOR: Help in test cases

help
implementation

#1

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


#2

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* + max becomes greater than a[i+1].


#3

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 https://www.codechef.com/viewsolution/17670384


#4

U need to make changes in a[i-1] not in a* and after that u will get write verdict.
https://www.codechef.com/viewsolution/17919387 i have made changes in ur solution and it has passed all the test cases


#5

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’


#6

I changed my code to a* == a[i - 1], it passes your test case but still fails many… please help again … https://www.codechef.com/viewsolution/17909979


#7

pls up vote


#8

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