# 51. 寻找连续区间-数组连续和

51

const readline = require('readline');
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});
let n = 0;
let x = 0;
let nums = [];
rl.on('line', function(line) {
    if (!n) {
        [n, x] = line.split(' ').map(Number);
    } else {
        nums = line.split(' ').map(Number);
        let left = 0;
        let right = 0;
        let count = 0;
        let sum = 0;

        while(right < n) {
            sum += nums[right];
            while(sum >= x) {
                count += n - right;
                sum -= nums[left];
                left++;
            }
            right++;
        }
        console.log(count);
    }
});
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30