We want to give incentives to driver. So we need to devise a mechanism to calculate these incentives.
On the end of every trip, an Uber driver gets rating for the ride which is averaged per day. For a given period of days, the value of driver is computed as the sum of the rating of the days in the given period, multiplied by the least rating in that period.
For example
The average ratings for some 4 days are:
2, 1, 3, 4
The the value of driver over these days is (2 + 1 + 3 + 4) * 1 = 10
Let’s create a hypothesis that the incentive calculated is proportional to the greatest value over any contiguous period in drivers days on Uber. Given driver’s average ratings per day, return this greatest value.
Example
Input
Given driver’s ratings over 6 days:
[3, 1, 6, 4, 5, 2]
Output
60
Explanation
Then the period from day 3 to day 5, i.e. 6, 4, 5 has the greatest value, which is (6 + 4 + 5) * 4 = 60
[execution time limit] 1 seconds (cpp)
[input] array.integer ratings
Array of integers. a[i] represents average integer rating on i’th day. Size of array <= 10^5. 0 <= a[i] <= 10^6.
[output] integer64
The greatest value of any contiguous period throughout whole period in given array.
can anyone help me that how to solve this problem
@ssrivastava990 @ssjgz @akshitm16