题目描述
知识点: 双指针
思路: 坑题。。题目的意思是从这个序列中随便选数字,满足题目性质的最长序列长度是多少。。
可以先排序,然后枚举最大值,同时最小值满足单调性,不可能往后退只能往前走,所以可以用双指针枚举过程中记录长度。
#include
#include
using namespace std;
const int N = 1e5+10;
typedef long long ll;
int a[N],n,p;
int ans = 0;
int main(){
scanf("%d%d",&n,&p);
for(int i = 0;i < n;i++) scanf("%d",&a[i]);
sort(a,a+n);
for(int i = 0,j = 0;i < n;i++){
while((long long)a[j] * p < a[i]) j++;
ans = max(ans,i-j+1);
}
cout<<ans;
return 0;
}