Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main() {
- int t;
- cin>>t;
- while(t--)
- {
- int n;
- cin>>n;
- vector<int>v(n);
- for(int i=0;i<n;i++)
- {
- cin>>v[i];
- }
- int k;
- vector<pair<int,int> >v1;
- cin>>k;
- for(int i=0;i<n;i++)
- {
- for(int j=i+1;j<n;j++)
- {
- if(abs(v[i]-v[j])==k)
- {
- v1.push_back({v[i],v[j]});
- }
- }
- }
- sort(v1.begin(),v1.end());
- int sz=unique(v1.begin(),v1.end())-v1.begin();
- cout<<sz<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement