C ++ implementation of the approach
#include <bits/stdc++.h> NEW_LINE using namespace std ; #define MAX  10000 NEW_LINE #define MAX_ELEMENT  50 NEW_LINE int dp [ MAX_ELEMENT ] [ MAX_ELEMENT ] [ MAX ] ;