Problem link: CodeChef: Practical coding for everyone
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
tamo11
November 29, 2020, 5:53pm
2
1
4
4
1 1 1 3
your output-2
correct output-1
Thanks and Regards
9 Likes
This is some GOD level stupidity that you’ve done, dude there’s no need of hosting such trash contests. Kindly learn to value everyone’s time
3 Likes
Please don’t arrange any contest like this in future.
Many were getting WA though their code was absolutely correct.
2 Likes
Ok Guys, That was my first attempt to contribute to the coders society.
I felt badly…
As learning is exponential constant for me…
I am updating myself.
Hope in future, I will contribute for good.