Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // In the name of Allah.
- // We're nothing and you're everything.
- // Ya Ali!
- /*
- , \ / ,
- / \ )\__/( / \
- / \ (_\ /_) / \
- ____/_____\__\@ @/___/_____\____
- | |\../| |
- | \VV/ |
- | ------___------- |
- |__________Chuta Dragon___________|
- | /\ / \\ \ /\ |
- | / V )) V \ |
- |/ ` // ' \|
- ` V '
- */
- #include<bits/stdc++.h>
- using namespace std;
- typedef long long ll;
- #define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL))
- #define fi first
- #define se second
- #define pb push_back
- ll const MOD=1000000007;
- ///-------------------------------------------------------------------------------------------------///
- /// KARMA IS LIKE 69,,, YOU GET WHAT YOU GIVE ///
- ///-------------------------------------------------------------------------------------------------///
- #define eb emplace_back
- int main()
- {
- fastread();
- ll n,k;
- cin>>n>>k;
- ll cnt=0,ara[n+1];
- for(ll i=0;i<n;i++)
- {
- cin>>ara[i];
- // if(a<k)cnt++;
- }
- sort(ara,ara+n);
- ll sum=0;
- for(ll i=0;i<n;i++)
- {
- ll a;
- a=k-ara[i];
- //cout<<a<<endl;
- if(a>0) {
- ll pos=lower_bound(ara,ara+n,a)-ara;
- // cout<<pos<<" pos"<<endl;
- cnt=pos-i-1;
- if(cnt>0)sum+=cnt;
- // cout<<cnt<<endl;
- // break;
- }
- }
- // cout<<cnt<<endl;
- // cout<<(cnt*(cnt+1))/2<<endl;
- cout<<sum<<endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement