TheForces Round #16 (2^4-Forces) Editorial

Revision en23, by wuhudsm, 2023-06-12 12:45:30

A

code

B

code
Solution

C

code
Solution

D

code
Solution

E

code
Solution

Consider DP.

Note $$$dp_{i,j}$$$ as the maximum score we can get at the end of $$$(i,j)$$$.

Note $$$lmax_{i,j}=max(0,max_(1 \leq k \leq j)((a_{i,k}-2c)+...+(a_{i,j}-2c)))$$$ and $$$rmax$$$ similarly.

Now consider which cell we go from to $$$(i,j)$$$.There are four situations.

$$$1.$$$ We just start at $$$(i,j)$$$.The answer is $$$a_{i,j}+lmax_{i,j-1}+rmax_{i,j+1}$$$;

$$$2.(i-1,j) \rightarrow (i,j)$$$.The answer is $$$dp_{i-1,j}-c+a_{i,j}+lmax_{i,j-1}+rmax_{i,j+1}$$$;

$$$3.(i,j-1) \rightarrow (i,j)$$$.The answer is $$$left_{i-1,j}-c+a_{i,j}+rmax_{i,j+1}$$$;

$$$4.(i,j+1) \rightarrow (i,j)$$$.The answer is $$$right_{i+1,j}-c+a_{i,j}+lmax_{i,j-1}$$$.

$$$left_{i,j}=max(max(0,dp_{i-1,j}-c)+a_{i,j}+lmax_{i,j-1},left_{i,j-1}-c+a_{i,j})$$$,and $$$right_{i,j}$$$ similarly.

$$$dp_{i,j}$$$ is the maximum value of the answers for the four situations mentioned above.And the final answer is $$$max(dp_{i,j})$$$.

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en28 English wuhudsm 2023-06-12 12:50:20 2 Tiny change: ' summary="Solution">\' -> ' summary="solution">\'
en27 English wuhudsm 2023-06-12 12:50:02 0 (published)
en26 English wuhudsm 2023-06-12 12:49:49 36
en25 English wuhudsm 2023-06-12 12:49:00 124
en24 English wuhudsm 2023-06-12 12:47:03 176 (saved to drafts)
en23 English wuhudsm 2023-06-12 12:45:30 3132 (published)
en22 English wuhudsm 2023-06-12 12:39:25 6811
en21 English wuhudsm 2023-06-12 12:35:46 2800
en20 English wuhudsm 2023-06-12 12:32:57 11
en19 English wuhudsm 2023-06-12 12:31:48 313 (saved to drafts)
en18 English wuhudsm 2023-06-12 12:10:19 2 Tiny change: 'r $y_i=0$,then can we' -> 'r $y_i=0$,when can we'
en17 English wuhudsm 2023-06-12 12:07:37 0 (published)
en16 English wuhudsm 2023-06-12 12:07:05 131
en15 English wuhudsm 2023-06-12 12:05:19 112 Tiny change: 'ons.\n\n$1$. We just s' -> 'ons.\n\n$1.$ We just s'
en14 English wuhudsm 2023-06-12 12:01:25 52
en13 English wuhudsm 2023-06-12 11:59:55 586
en12 English wuhudsm 2023-06-12 11:46:44 9
en11 English wuhudsm 2023-06-12 11:45:41 250
en10 English wuhudsm 2023-06-12 11:40:37 181
en9 English wuhudsm 2023-06-12 11:37:38 13
en8 English wuhudsm 2023-06-12 11:36:08 785
en7 English wuhudsm 2023-06-12 11:20:08 243
en6 English wuhudsm 2023-06-11 19:49:05 56
en5 English wuhudsm 2023-06-11 19:48:24 28
en4 English wuhudsm 2023-06-11 19:47:49 100
en3 English wuhudsm 2023-06-11 19:46:05 45
en2 English wuhudsm 2023-06-11 19:44:08 121
en1 English wuhudsm 2023-06-11 19:40:02 646 Initial revision (saved to drafts)