Untitled

mail@pastecode.io avatar
unknown
plain_text
17 days ago
404 B
2
Indexable
Never
#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;
}
Leave a Comment