#include<stdio.h>
#define M 20010
long cmp(const void *a, const void *b);
int main(int argc, char ** argv){
long n,s,l[M]={0},cnt[M]={0},sum=0;
int i,j,k;
while( scanf ("%ld%ld", &n, &s),n != 0 && s != 0){
for(i = 0;i < n; i++){
scanf("%ld", &l[i] );
}
qsort(l, n, sizeof(long ), cmp);
for(i = n-1;i >0 ; i--){
if( cnt[i+1] > 0) {
cnt[i] = cnt[i] + cnt[i+1]-1;
j=cnt[i+1] - 1;
}
else
j=cnt[i+1];
for(; j < i; j++){
if(l[i] + l[j] <= s) {
cnt[i]++;
}
else{
break;
}
}
}
for(i = 0;i < n; i++){
// printf("%ld ", cnt[i]);
sum+=cnt[i];
l[i]=0;
cnt[i]=0;
}
printf("%ld\n", sum);
sum=0;
}
}
long cmp(const void *a, const void *b){
return *(long *)a - *(long *)b ;
}
|