Dp vector
int [ ] [ ] [ ] dp = new int [ N + 1 ] [ K + 1 ] [ D + 1 ] ; for ( int i = 0 ; i < N + 1 ; i ++ ) { for ( int j = 0 ; j < K + 1 ; j ++ ) { for ( int k = 0 ; k < D + 1 ; k ++ ) { dp [ i ] [ j ] [ k ] = - 1 ; } } } for ( int i = 1 ; i <= N ; i ++ ) {