DESCRIPTION:
Given two arrays t and c denoting the treasure and color in each city. A city can be visited or skipped. You can only move forward. Whenever you visit a city you get the following amount.
Given that a, b, t[] can be negative and c[] varies from 1 to n.
Find the maximum money that can be earned by visiting each city.
Sample Input:
a = 5, b = -7
Array size = 4
Treasure array: {4, 8, 2, 9 }
Color array: { 2, 2, 3, 2 }
Sample Output:
Maximum profit: 57
Explanation:
Visit cities in the order 1 -> 2-> 4
Maximum profit = (-7 * 4) + (8 * 5) + (9 * 5) = 57
@@coding::1@@
Recommended Programs