Untitled
user_8661932
c_cpp
2 years ago
548 B
6
Indexable
#include <bits/stdc++.h>
using namespace std;
int fre(int a[],int n,int k){
int lo=0,hi=n-1;
int c=0;
while(lo<=hi){
if((a[lo]+a[hi])%k!=0){
c++;
hi--;
}else if((a[lo]+a[hi])%k < k/2){
lo++;
}
else{
hi--;
}
}
return c;
}
int main() {
int t;
cin>>t;
while(t--){
int n,k;
cin>>n>>k;
int a[n];
for(int i=0;i<n;i++){
cin>>a[i];
}
sort(a,a+n);
cout<<fre(a,n,k)<<endl;
}
return 0;
}Editor is loading...
Leave a Comment