Save Khandelwal !!!

5

1 votes
Medium
Problem

Rahul Khandelwal's girlfriend is little bit weak in maths and thus asks Rahul to help her in solving a problem.
The problem goes like this :
Given a list X of N integers, we need to choose two numbers A and B randomly where 0<=A<=B ( considering zero-based indexing ) such that sum (X[A],... X[B]) <= M.
Rahul needs to find the probability of the number of possible values of A and B satisfying the above condition. But Rahul too is stuck and thus needs your help.
Can you help him to solve the problem so that he can make his girlfriend happy ?

Input
The first line contains two integers N and M.
N lines follow, where each line contains an integer of the list X.

Output
Output a single number P to a maximum of 8 decimal places denoting the solution of the above problem.

Constraints
1<= N <105
0 <= X[i] < 1e7

Sample Input
5 10
4 
5 
3 
7
1
Sample Output
0.6
Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

X = [ 4, 5, 3, 7, 1].
Thus the total number of possibilites are
[4], [5] , [3], [7], [1], [4,5], [5,3], [3,7], [7,1] out of possible 15. thus 9/15 = 0.6

Contributers:
Editor Image

?