Need help in CF 313C

Revision en2, by MohamedHamada_, 2018-04-21 21:20:03

in the 313C i tried to solve it recursively. then i got WA (i expected either AC or TLE Due to the recursion complexity )

i tried this test :

16

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16

following the problem description , i have 2^2 * 2^2 matrix so i pick the max number = 16 and then divide the matrix to 4 2*2-matrices

next, for each 2*2 matrix i choose the max number and then divide each sub-matrix to another 4 submatrices of size 1*1

this the base case so the answer so far ( due to my solution ! )

= 16 + 6 + (1+2+5+6) +8 +(3+4+7+8) +14 + (9+10+13+14) +16+(11+12+15+16) = 196 [Wrong answer !]

i cloned an accepted code and tested my above test case and the answer = 210 (not 196 )

this is my Submission

any help appreciated , Thanks in advance :)

UDP :

i wasn't Sort the numbers in such way that maximize the answer , the right matrix for the above input :

and the answer = 16 +(16 + ( 11+12+8+16) + 15+(9+10+6+15) + 14+(3+4+7+14) + 13+(1+2+5+13)) = 210

thanks for you help.

Regards.

Tags 313c

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English MohamedHamada_ 2018-04-21 21:20:03 307 Tiny change: 'vance :) ' -> 'vance :) \n\n####UDP :\n\n#### Your title here...A '
en1 English MohamedHamada_ 2018-04-21 17:38:06 1081 Initial revision (published)