Exactly my thoughts. For the corner 1x1 case, shouldn’t we output min(x, y)? I got WA solely due to this reason.
Can someone tell me for case 3 3 20 19 how the ans=95?
Can anyone tell me the case when my solution wont work?
https://www.codechef.com/viewsolution/36013917
1
1 1 6 4
you code gives output 4 but it should be 6, as answer for 1by1 matrix will be x always
3*3 = 9 cells total , out of these 9 one can fill max of X(20) in each cell but as per condition - two adjacent cells can only have max value which would be equal to Y(19).
so we can fill 9/2+1 cells as 19 which is max and hence maintain the condition of adjacent pairs to be equal to 19.
I saved a lot of time because of your comment. Thanks
put 19 candies in both diagonals of matrix and zero candies in rest
In the case of 1*1 matrix, there are no adjacent pairs, so the answer should be x not min(x,y).
1
1 1 6 4
output-6
Suppose I take max = x and min = y - x and say the matrix is 4X3
Then I can arrange it like :
max min max
min max min
max min max
min max min
Any adjacent pair will always have sum = x + (y-x) = y
What is wrong with this approach?
Oh, I was thinking that even if there’s just one cell, it has to follow the condition of sum being less than y. Thanks a lot!
try 1 1 4 1 answer will be 4 not 1
can someone tell me .Whats wrong with my code? @cherry0697 @younoknowme
https://www.codechef.com/viewsolution/36010742
OMG cant believe that is cost me 100
I got it now - was printing min of x and y in case of n * m = 1.
can we see the test case on which our solution failed?
19 0 19
0 19 0
19 0 19
ans = 95