Creating a DP array to keep count of max score at ith element and it will be filled in the bottom Up manner
vector < int > dp ( * max_element ( a . begin ( ) , a . end ( ) ) + 1 , 0 ) ; dp [ 0 ] = 0 ; dp [ 1 ] = freq [ 1 ] ;