$A.\,\,\, B[i][j] = max(B[i-1][j-1],\,\,A[i]+B[i-1][j])$ // if we pick this value at index $i$ or not
$B.\,\,\, for(i=0\,\,to\,\,n)score=max(score, B[i][k])$
$C.\,\,\,Time\,Complexity : O(nk), \,\,Space\,Complexity:O(n)$
Space complexity is $O(n)$ as for calculating $B[\,][j]$ we only need values in $B[\,][j-1]$. So, no need to store all the values, and also at last we only need values in $B[\,][k]$ for calculating the score.