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
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].
I changed my code to a[i] == a[i - 1], it passes your test case but still fails many… please help again … https://www.codechef.com/viewsolution/17909979
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
U need to make changes in a[i-1] not in a[i] 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
pls up vote
otherwise it will fail on all the test cases in which no are reapeated more than twice.