Problem link: https://www.codechef.com/PPW12020/problems/ANITGUY1

Difficulty:

moderate

Solution:

#include <bits/stdc++.h>

using namespace std;

// driver code

int main()

{

```
int t;
cin>>t;
while(t--){
int k,n;
cin>>k>>n;
int arr[n];
for(int i=0;i<n;i++)cin>>arr[i];
sort(arr,arr+n);
int ans=0;
for(int i=0;i<n;i++){
if(binary_search(arr,arr+n,k-arr[i]))ans++;
}
cout << ans/2 << endl;
}
return 0;
```

}

Time : 0.1sec

Thanks and Regards