C++ 代码
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long LL;
const int N=1e5+10;
LL a[N];
int main()
{
int n,p;
scanf("%d%d",&n,&p);
for(int i = 0;i < n;i++) scanf("%d",&a[i]);
sort(a,a+n);
int res=0;
for(int i = 0,j = 0;i < n;i++)
{
while(j < n&&(LL)a[i]*p >= a[j]) j++;
res=max(res,j-i);
}
printf("%d\n",res);
return 0;
}