-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathsd.cpp
More file actions
40 lines (31 loc) · 689 Bytes
/
sd.cpp
File metadata and controls
40 lines (31 loc) · 689 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
int t,n,m,i,p;
cin>>t;
while(t--)
{ int count1=0;
cin>>n>>m;
vector<int> v;
vector<int> v1;
for(i=0;i<n;i++)
{
cin>>p;
v.push_back(p);
}
vector<int>:: iterator it,j,k;
sort(v.begin(),v.end());
for(i=0;i<n;i++)
{
it=v.begin()+i;
int fin=m-*it;
if(fin==*it)
count1--;
if(binary_search(v.begin()+i,v.end(),fin))
count1++;
}
cout<<count1<<"\n";
}
}