To check if a state has been solved
if ( v [ i ] ) : NEW_LINE INDENT return dp [ i ] ; NEW_LINE DEDENT v [ i ] = 1 ; NEW_LINE if ( i == 0 ) : NEW_LINE INDENT x = prefix_sum [ k - 1 ] ; NEW_LINE DEDENT else : NEW_LINE INDENT x = prefix_sum [ i + k - 1 ] - prefix_sum [ i - 1 ] ; NEW_LINE DEDENT