Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- #define nguyendz the_best
- #define all(n) n.begin(),n.end()
- #define ll int
- #define ld long double
- #define pb push_back
- #define eb emplace_back
- #define endl "\n"
- #define pll pair<ll,ll>
- #define YES cout <<"YES"<<endl;
- #define NO cout <<"NO"<<endl;
- #define ff first
- #define ss second
- //#define ((x|y)-y) (x&(~y))
- using namespace std;
- const ll maxn=1e4+2;
- const ll maxx=1e13;
- const ll mod=1e9+7;
- const ll mod1=998244353;
- ll kc,t,n;
- struct tk
- {
- ll id,val;
- };
- ll a[maxn];
- int main()
- {
- // freopen("test.txt","r",stdin);
- // freopen("CHEMIST.OUT","w",stdout);
- ios_base::sync_with_stdio(false);
- cin.tie(0);
- cout.tie(0);
- ll n,l,r;
- cin>>n>>l>>r;
- for (int i=1;i<=n;i++)
- {
- ll k;
- cin>>k;
- a[i]=a[i-1]+k;
- }
- sort(a+1,a+n+1);
- ll ans=0;
- for (int i=1;i<=n;i++)
- {
- ll t1=a[i-1]+l,t2=a[i-1]+r;
- ll d=1,h=n;
- while (d<=h)
- {
- ll m=(d+h)/2;
- if (a[m]<t1) d=m+1;
- else h=m-1;
- }
- ll v1,v2;
- v1=d;
- d=1,h=n;
- while (d<=h)
- {
- ll m=(d+h)/2;
- if (a[m]<t2) d=m+1;
- else h=m-1;
- }
- v2=d;
- // cout <<v1<<" "<<v2<<endl;
- ans=ans+v2-v1+1;
- }
- cout <<ans;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement