×

# MIXCOLOR: Help in test cases

 0 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 asked 17 Mar '18, 16:21 0★montycs 105●7 accept rate: 0%

 1 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]. answered 18 Mar '18, 19:52 3★anshul99 26●3 accept rate: 33% 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 (19 Mar '18, 13:46) montycs0★
 1 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 answered 20 Mar '18, 17:21 293●6 accept rate: 33% pls up vote (20 Mar '18, 17:21) otherwise it will fail on all the test cases in which no are reapeated more than twice. (20 Mar '18, 17:23)
 1 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 answered 19 Mar '18, 14:06 216●1●5 accept rate: 11%
 1 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' answered 20 Mar '18, 17:58 90●3 accept rate: 25%
 toggle preview community wiki:
Preview

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported
• mathemetical formulas in Latex between \$ symbol

Question tags:

×2,714
×825

question asked: 17 Mar '18, 16:21

question was seen: 275 times

last updated: 20 Mar '18, 17:58