Guest User

Untitled

a guest
Jun 14th, 2017
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5. long long int i,n,j,k,ans=0,p,up;
  6. cin>>n>>k;
  7. vector<long long int>v;
  8.  
  9. long long int a[n];
  10. for(i=0;i<n;i++)
  11. {
  12. cin>>p;
  13. v.push_back(p);
  14. }
  15.  
  16. sort(v.begin(),v.end());
  17. for(i=0;i<n;i++)
  18. {
  19. if(v[i]<=(k-1)/2)
  20. {
  21. up=upper_bound(v.begin(),v.end(),k-1-v[i])-v.begin();
  22. // cout<<v[i]<<" "<<i<<" "<<up<<endl;
  23.  
  24. ans+=(up-1-i);
  25.  
  26. }
  27. }
  28. cout<<ans;
  29. return 0;
  30. }
Add Comment
Please, Sign In to add comment