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
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
so answer will be min(Arr[y-1],Arr[Y+1])
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 !
Sudheera Y S
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
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.
4 2 0
3 2 4 3
Output given by the user
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.
can you tell me the ide where you get this output for such input as on intellij i am get normal output
Codechef IDE. You can see it on the submisssions page, then on top choose switch to IDE mode.