Source:
Description:
Input Specification:
Output Specification:
Sample Input:
Sample Output:
Keys:
- 双指针
Code:
#include<cstdio>
#include<algorithm>
using namespace std;
const int M=1e5+;
typedef long long LL; int main()
{
#ifdef ONLINE_JUDGE
#else
freopen("Test.txt", "r", stdin);
#endif // ONLINE_JUDGE LL n,p,s[M];
scanf("%lld%lld", &n,&p);
for(LL i=; i<n; i++)
scanf("%lld", &s[i]);
sort(s,s+n);
LL i=,j=,step=;
while(j < n)
{
while(j<n && s[j]<=s[i]*p)
j++;
if(j-i > step)
step = j-i;
i++;
j=i+step;
}
printf("%lld", step); return ;
}