You re right, but this code runs slower
#include <iostream>
#include <cstring>
#define ABS(x) ((x<0)?(-(x)):(x))
using namespace std;
int main(){
int N,B,i,j,k,c,dif;
int R[91];
int balls[91];
while(cin>>N>>B,N,B){
memset(balls,0,sizeof(balls));
for(i=0;i<B;++i)
cin>>R[i];
k=c=0;
for(i=0;i<B;++i){
for(j=i+1;j<B;++j){
dif=ABS(R[i]-R[j]);
if(!balls[dif]){balls[dif]=1; c++;}
k++;
}
}
if(c==N)cout<<"Y";
else cout<<"N";
cout<<endl;
}
}
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.