Help me in Beautiful arrays

I am stuck at beautiful arrays.I have considered every possible test case as best of my thinking but it is still showing WA.Please point out any logical error in my code.
here’s my code
https://www.codechef.com/viewsolution/14306439

Are you considering that an array of size 1 is beautiful by definition?

1 Like

No. I am not considering that array to be beautiful. Is it beautiful??

It is, by definition (in opinion of problem setter)

though u are right.but still i am unable to figure out which words of problem setter indicate that array of size 1 is beautiful.Can you please quote that line from which it is clearly indicated.

For size 1, there are no pairs, so “every pair” will always satisfy the conditions.

I m not getting it.For a pair there must be 2 elements but if size is 1 that means no pair exist.So how can it satisfy the conditions which are supposed to be satisfied by pairs?

Check comments of @dpraveen here - https://discuss.codechef.com/questions/86332/problem-with-icpc16b-beautiful-arrays

1 Like