L2 will sum the values of those indices of ways [ ] which is equal to ( N - ( c * 10 + d * 20 ) )
for ( int c = 0 ; c <= C && c * 10 <= ( N ) ; c ++ ) { for ( int d = 0 ; d <= D && c * 10 + d * 20 <= ( N ) ; d ++ ) { ans += ways [ N - c * 10 - d * 20 ] ; } }