测试点4死活过不去,以后再想吧。。。
测试点三是长度为1.
#include<bits/stdc++.h>
using namespace std;
vector<long long> v;
int main() {
int maxnum = 0, n;
long long p, len = 0;
scanf ("%ld %lld", &n, &p);
vector<long long> v(n);
for (int i = 0; i < n; i++) scanf ("%lld", &v[i]);
sort (v.begin(), v.end());
for (int i = v.size() - 1, j = i; i >= 0; i--) {
for ( ; j >= 0; j--) {
if (v[i] <= v[j] * p) {
if (maxnum < i - j + 1) maxnum = i - j + 1;
}
}
}
printf ("%d", maxnum);
return 0;
}