1085 Perfect Sequence (25 分)【简单 / 双指针】
作者:互联网
https://pintia.cn/problem-sets/994805342720868352/problems/994805381845336064
#include<bits/stdc++.h>
using namespace std;
typedef long long int LL;
const int N=1e5*2+10;
LL a[N],n,p;
int main(void)
{
cin>>n>>p;
for(int i=0;i<n;i++) cin>>a[i];
sort(a,a+n);
int ans=0;
for(int i=0,j=0;i<n;i++)
{
while(j<n&&a[j]*p<a[i]) j++;
ans=max(ans,i-j+1);
}
cout<<ans<<endl;
}
标签:Perfect,25,1085,994805381845336064,int,LL,long 来源: https://blog.csdn.net/qq_46527915/article/details/121246923