Game With Array

Codeforces Round #643 (div. 2)

 

 

So, first of All, let's go through the thought process of the Solution

 

Consider n = 5 and sum = 5

1

1

1

1

1

The sum goes from 1 to 5  

 

So, first of All, let's go through the thought process of the Solution

 

Consider n = 5 and sum = 5

1

1

1

1

1

The sum goes from 1 to 5  

No possible Solution!!

 

So, first of All, let's go through the thought process of the Solution

 

Consider n = 5 and sum = 6

1

1

1

1

The sum goes from 1 to 6

still No possible Solution!!

1

1

1

1

2

 

So, first of All, let's go through the thought process of the Solution

 

Consider n = 5 and sum = 7

1

1

1

Both the cases The sum goes from 1 to 7

still No possible Solution!!

1

1

1

2

2

1

1

1

1

3

OR

 

So, first of All, let's take one more

Consider n = 5 and sum = 8

1

1

For all arrangements, The sum goes from 1 to 8

still No possible Solution!!

1

1

2

2

2

1

1

1

1

4

OR

There can be more arrangements too but they will all result in same sum

 

So, Question Arises Till what sum we will keep getting all sums

Consider n = 5 and sum = 10

2

For arrangement 1, The sum goes from 2 to 10

 

1

1

2

2

2

1

1

1

1

6

OR

2

For arrangement 2, The sum goes from 1 to 4 and from 6 to 10

 

 

So, Question Arises Till what sum we will keep getting all sums

Consider n = 5 and sum = 10

2

For arrangement 1, The sum goes from 2 to 10

And sum 1 is missing so it is the answer

 

1

1

2

2

2

1

1

1

1

6

OR

2

For arrangement 2, The sum goes from 1 to 4 and from 6 to 10

And sum 5 is missing so it is the answer

 

 

Conclusion

1

Observe sum >= 2n there is an answer 

otherwise, there are no answers

 

Finding the answer

we have already talked about two of the arrangments you can take any arrangments of your choice 

2

2

2

2

2

For this arrangement answer will always be 1

1

1

1

1

1

1

6

For this arrangement in which n-1 elements will have 1 and nth array index will contain sum - (n-1)

The Answer Will be number of ones + 1

Made with Slides.com