It's graphics time! For an assignment, you used separate methods to draw your objects. However, it seems that Ready to Program cannot seemingly handle all your (totally) amazing drawings (without exploding and probably somehow cause the RtP equivalent of an IE on DMOJ)! You have given each of your objects a value, , which represents their style point. You also created queries to determine how many style points you will receive if you commented out every object except those in the range of the query. Out of these queries, determine the maximum number of style points you can score!
DISCLAIMER: Python CANNOT PASS (and now is no longer a submittable language)
Constraints
Subtask 1 [20%]
Subtask 2 [80%]
Input Specifications
The first line will contain two space-separated integers, .
The next line will contain space-separated integers, , the style points of each object.
The next lines will contain two space-separated integers , describing the range of the indices, inclusive.
Output Specifications
The first lines of your output should contain a single integer on each line, the sum of all the style points from to .
The th line should contain an integer , with , the query that has the highest style points. If there is a tie, output the query that appears first in the sample input.
Sample Input
3 2
5 6 -1
1 2
2 3
Sample Output
11
5
1
Sample Case Explanation
The first query contains the objects 5 and 6, which has a sum of 11. The second query contains the objects 6 and -1, which has a sum of 5. Since query 1 has a greater value than query 2, then the number on the last line is 1.
Comments