New problem on Probability

1.7

6 votes
Medium
Problem

enter image description here

Mayank is given an array named as K and the size of the array is L , and given a number “T” such that he has to choose randomly maximum two numbers, X and Y such that 0 <= X < Y< L.

What is the probability that sum{K[X]...K[Y] } <= T }?

Input Format:

The first line will contain two numbers: L and T. L lines follow, each containing one number from the array K.

Output Format:

Output one number P to a maximum of 8 decimal places, the probability that sum{K[X],... k[Y]} <= T}

Constraints:

1 <= N < 100000 0 <= D[i] < 10^7

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

[4,5,3,7,1]

[4], [5], [3], [7], [1], [4,5], [5,3], [3,7], [7,1]

Out of possible 15.

Thus 9/15 = 0.6

Editor Image

?