Untitled

mail@pastecode.io avatar
unknown
pascal
2 years ago
317 B
74
Indexable
Never
const Max_PrefixSum=200000000;
var n,k,x,t,ans,i,a:longint;
    b:array[-Max_PrefixSum..Max_PrefixSum] of longint;

begin
    readln(n,k);
    b[0]:=1;
    for i:=1 to n do 
    begin
        read(x);
        t:=t+x;
        ans:=ans+b[t-k];
        inc(b[t]);
    end;
    write(ans);
    readln
end.