# PAT 1085. Perfect Sequence (25)

#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;

int n;
long long a[100005];
int midSearch(int i,long long max)
{
int left = i,right = n;
while(left < right)
{
int mid = (left + right)/2;
if(a[mid] > max)
{
right = mid - 1;
}else if(a[mid] < max)
{
left = mid +1;
}else
break;
}
if(a[(left + right)/2] == max)
return (left + right)/2 - i +1;
else
return (left + right)/2 - i;
}
int main()
{
int p;
while(cin>>n>>p)
{
for(int i = 0; i < n; i++)
cin>>a[i];
sort(a,a+n);
int t = 0;
for(int i = 0; i < n; i++)
{
long long max = a[i] * p;
int number  = midSearch(i,max);
if(t <= number)
t = number;
}
cout<<t<<endl;
}
return 0;
}

#### pat 1085. Perfect Sequence (25)

2014-09-06 21:58:54

#### 1085. Perfect Sequence (25) -二分查找

2015-08-11 14:27:05

#### pat 1085

2015-02-20 20:49:14

#### PAT 乙级 1085. PAT单位排行 (25) 【结构体排序】

2018-03-27 17:12:25

#### 1085. PAT单位排行 (25) PAT乙级真题

2018-03-27 18:36:59

#### 1085. PAT单位排行 (25)

2018-03-19 09:54:07

#### PAT 1085. PAT单位排行 (25) - 乙级

2018-03-24 21:59:15

#### 【PAT】1085. Perfect Sequence (25)

2014-11-05 15:48:03

#### 1085. Perfect Sequence (25) PAT

2016-06-01 18:10:16

#### 1085. Perfect Sequence (25) 二分查找法

2018-01-27 11:41:59