Code works on local ide but shows wrong answer on codechef

problem: https://www.codechef.com/problems/RAINBOWA

my code : https://www.codechef.com/viewsolution/15166972

i’ve tested all the sample outputs and it works properly on my local ide. Can anybody please tell me why is shows wrong answer?

for this test case answer should be no…

1
17
1 2 3 4 5 6 7 7 8 7 7 6 5 4 3 2 1

as per my understanding of the problem, the array should be increasing by 1 or equal upto middle term and then the same array should be there in other half. So, the above test case that you wrote should give answer yes.

Nope… Array should increase only till 7… so above answer should be no…

An array is Rainbow if it has the following structure:

First a1 elements equal 1.

Next a2 elements equal 2.

Next a3 elements equal 3.

Next a4 elements equal 4.

Next a5 elements equal 5.

Next a6 elements equal 6.

Next a7 elements equal 7.

Next a6 elements equal 6.

Next a5 elements equal 5.

Next a4 elements equal 4.

Next a3 elements equal 3.

Next a2 elements equal 2.

Next a1 elements equal 1.

Hi @prince90,

The rainbow has 7 colours, so the max value in your rainbow array should be 7.

//