Code is available at https://codeforces.com/contest/1965/submission/258446500.
The maximum cost is 348800. I hope the reader is entertained.
Alternative solution for E. Connected Cubes with less blocks
Code is available at https://codeforces.com/contest/1965/submission/258446500.
The maximum cost is 348800. I hope the reader is entertained.