Can Anyone Explain The main problem BOXGAM97 , i think i misunderstood

Here is the problemProblem

Hi @kushoz !

They toss a coin and the give the ball to the winner of the toss
There are n boxes in a row and each box has a number written on it

The guy who wins the toss can put the ball in any box
Then they play for K rounds
In each round they play alternatively

When it is someoneâ€™s round , he should move the ball to the box left to it or right to it unless it doesnt go out of the boundaries

And they do this till k rounds

Jafar plays in such a way that when the game ends, the number on the box which contains the ball is the biggest possible. On the contrary, Almir wants this number to be the smallest possible.

You know which player moves first. Determine the result of the game, assuming that both players play optimally that is determine the number written on the box which contains the ball if they play optimally

Hope you understand this

Sudheera Y S

3 Likes

thanks for your effort â€¦i was just asking for logic that my logic is based upon that the answer will be around max/min or equal to max/min equal when number of turn is odd but in case for number of turn is even
let max index be = Y and Array be :â€“> Arr[]
and vice versa
so is this logic wrong?

I dont think this is correct
Think for some time and then if you dont get it then read the editorial !

No problem
Sudheera Y S

1 Like

You are right but you are missing an edge caseâ€¦ What happens if you place a coin in ends of the array??

Since i am new to codechef , i thought it will give me null pointer exception for index+1 and index -1
can u look at my solution and tell me still where i am wrong?

here is the solutionSolution

Mmm ,

I donâ€™t see anything wrong in your code. I code in c++, thus I donâ€™t know whether the following holds the truth or not.

I have tested your test with various inputs, and all of the answers were correct, but something else was shown too.

Eg:

Input

4 2 0
3 2 4 3

Expected Output

4

Output given by the user

4
java.util.NoSuchElementException
at java.util.Scanner.throwFor(Scanner.java:862)
at java.util.Scanner.next(Scanner.java:1485)
at java.util.Scanner.nextInt(Scanner.java:2117)
at java.util.Scanner.nextInt(Scanner.java:2076)
at Codechef.main(Main.java:22)

I donâ€™t know whether this is the problem with your code, but you can always try it out

can u please tell what else was shown too?

I had shown this in my previous reply. I had hidden this in the topic â€śOutput given by the userâ€ť. To view it, just click on that.