/1633.cpp Secret
Created
February 12, 2022 09:24
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int solve(int idx, int b_cnt, int w_cnt){ | |
if(idx == N) return 0; | |
if(b_cnt == 15 && w_cnt == 15) return 0; | |
int &ret = cache[idx][b_cnt][w_cnt]; | |
if(ret != -1) return ret; | |
// Skip | |
ret = max(ret, solve(idx + 1, b_cnt, w_cnt)); | |
// White | |
if(w_cnt < 15) | |
ret = max(ret, solve(idx + 1, b_cnt, w_cnt + 1) + arr[idx][0]); | |
// Black | |
if(b_cnt < 15) | |
ret = max(ret, solve(idx + 1, b_cnt + 1, w_cnt) + arr[idx][1]); | |
return ret; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment