Untitled

 avatar
unknown
plain_text
a year ago
404 B
3
Indexable
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

ll p[1000001];

int i, n, k, tmp;
ll cnt = 0;

int main() {
    
    cin >> n >> k;
    for(i = 0; i < n; i++){
        cin >> tmp;
        p[i+1] = p[i] + tmp;
    }
    
    for(i = 1; i <= n; i++)
        cnt += p+i - lower_bound(p,p+i,p[i]-k);

    cout << cnt << endl;
     
    return 0;
}
Editor is loading...
Leave a Comment