human
Highway Billboard Problem | Python3 program to find maximum revenue by placing billboard on the highway with given constraints ..
Array to store maximum revenue at each miles ..
actual minimum distance between 2 billboards ..
check if all billboards are already placed ..
check if we have billboard for that particular mile . If not , copy the previous maximum revenue ..
we do have billboard for this mile ..
If current position is less than or equal to t , then we can have only one billboard ..
Else we may have to remove previously placed billboard.
Driver Code"
Solution in Python:
 Give me a code to highway Billboard Problem and the other steps required?
assistant
#Here is code to highway Billboard Problem and the other steps required.
 def maxRevenue ( m , x , revenue , n , t ) :
	maxRev = [ 0 ] * ( m + 1 )
	nxtbb = 0 ;
	for i in range ( 1 , m + 1 ) :
		if ( nxtbb < n ) :
			if ( x [ nxtbb ] != i ) :
				maxRev [ i ] = maxRev [ i - 1 ]
			else :
				if ( i <= t ) :
					maxRev [ i ] = max ( maxRev [ i - 1 ] , revenue [ nxtbb ] )
				else :
					maxRev [ i ] = max ( maxRev [ i - t - 1 ] + revenue [ nxtbb ] , maxRev [ i - 1 ] ) ;
				nxtbb += 1
		else :
			maxRev [ i ] = maxRev [ i - 1 ]
	return maxRev [ m ]
if __name__ == " _ _ main _ _ " :
	m = 20
	x = [ 6 , 7 , 12 , 13 , 14 ]
	revenue = [ 5 , 6 , 5 , 3 , 1 ]
	n = len ( x )
	t = 5
	print ( maxRevenue ( m , x , revenue , n , t ) )