| RMQ Overkill | 
 i
i j < 10000) [N is the size of the sequence], you
have to find the minimum integer in that range, and add the minimums for all those queries
together. When you are done that, mod the sum with 1000000007 and print.
j < 10000) [N is the size of the sequence], you
have to find the minimum integer in that range, and add the minimums for all those queries
together. When you are done that, mod the sum with 1000000007 and print.
For each case :
First line, an integer N (
1 N
N 10000), the size of the array.
Second line, a string of N characters where i-th character denotes the i-th element of the
sequence.
10000), the size of the array.
Second line, a string of N characters where i-th character denotes the i-th element of the
sequence.
Output Explanation
First case: all possible queries and there results are, (0, 0) = > 1, (0, 1) = > 1, (0, 2) = > 1, (1, 1) = > 4, (1, 2) = > 3, (2, 2) = > 3. So, R = 1 + 1 + 1 + 4 + 3 + 3 = 13.
Second case: all possible queries and there results are, (0, 0) = > 4, (0, 1) = > 1, (0, 2) = > 1, (1, 1) = > 1, (1, 2) = > 1, (2, 2) = > 3. So, R = 11.
Third case: all possible queries and there results are, (0, 0) = > 1, (0, 1) = > 1, (0, 2) = > 1, (1, 1) = > 2, (1, 2) = > 1, (2, 2) = > 1. So, R = 7.
3 143 3 413 3 121
13 11 7
Problem Setter: Pratyai Mazumder 
Alternate Solution: Mohammad Hafiz Uddin