G.W. Coding Contest 2 P3: Speeding Students
Recently, there has been an increase in speeding near G.W Williams. The students and staff both find this very annoying, so the police has decided to implement a new speeding policy.
For \(N\) seconds, the police will measure the speed of the car and will look at \(Q\) queries. Each query two numbers \(A\) and \(B\); if the average speed of the car from second \(A\) to \(B\) is greater than a given number \(M\), then they are considered speeding.
Their fine will be calculated as (average speed-\(M\))\(\times 10\). If multiple queries go over the speed limit the answer will use the highest fine.
The first line of input will include \(N\), \(Q\), and \(M\). A single car's speed is recorded for \(N\) seconds, where \(N\) is a positive integer \(\{N > 1\}\). \(Q\) is a positive integer representing the number of queries. \(M\) is a positive integer representing the speed limit.
The next \(N\) lines will contain an integer \(\{ < 10^9\}\) representing the speed of the car at each second. The next \(Q\) lines will contain two integers, \(A\) and \(B\). \(A\) is the start time and \(B\) is the end time \(\{ A < B \text{ and } B \leq N, A \geq 1 \}\).
The output will consist of a single integer, representing the fine the car driver must pay. This value will be rounded down to the nearest integer. If there are no instances of speeding found, output \(-1\)
Sample Input 1:
Sample Output 1:
Sample Input 2:
Sample Output 2:
Submit Solution