AMR11H  Array Diversity
Enough with this Harry Potter, please! What are we, twelveyear olds? Let's get our teeth into some real pumpkin pasties  oops, programming problems!
Here we go!
Let's define the diversity of a list of numbers to be the difference between the largest and smallest number in the list.
For example, the diversity of the list (1, 1, 2, 7) = 7  (1) = 8.
A substring of a list is considered a nonempty sequence of contiguous numbers from the list. For example, for the list (1,3,7), the substrings are (1), (3), (7), (1,3), (3,7), (1,3,7). A subsequence of a list is defined to be a nonempty sequence of numbers obtained by deleting some elements from the list. For example, for the list (1,3,7), the subsequences are (1), (3), (7), (1,3), (3,7), (1,7), (1,3,7).
Given a list of length N find the number of substrings and subsequences in this list with the maximum diversity. If a substring/subsequence having maximum diversity occurs multiple times in the list, each of its occurences adds towards the answer. And tell Harry Potter your answer
Input (STDIN):
The first line contains T, the number of test cases. Then follow T test case blocks.
Each blocks starts with the first line containing the number N.
The second line contains a list of numbers in this list.
Output (STDOUT):
For each test case, output the number of substrings and the number of subsequences in this list with the maximum diversity.
Since the answers maybe very large, output them modulo 1000000007.
Constraints:
T <= 10
N <= 100,000
Each number in the list is between 1 and 100,000 inclusive.
Sample Input:
3
3
1 2 3
4
1 4 3 4
3
3 2 1
Sample Output:
1 2
3 6
1 2
hide comments
YangYue:
20130108 13:05:54
the output if all N elements are equal should be (n * (n + 1) / 2, 2 ^ n 1)


Abhishek Kandoi:
20121226 12:58:07
I am getting TLE around 9th Test Case, any help?

Added by:  Varun Jalan 
Date:  20111215 
Time limit:  0.404s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All except: ASM64 
Resource:  Pratik Tandel  ICPC Asia regionals, Amritapuri 2011 