测试点4死活过不去,以后再想吧。。。

测试点三是长度为1.

  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. vector<long long> v;
  4. int main() {
  5. int maxnum = 0, n;
  6. long long p, len = 0;
  7. scanf ("%ld %lld", &n, &p);
  8. vector<long long> v(n);
  9. for (int i = 0; i < n; i++) scanf ("%lld", &v[i]);
  10. sort (v.begin(), v.end());
  11. for (int i = v.size() - 1, j = i; i >= 0; i--) {
  12. for ( ; j >= 0; j--) {
  13. if (v[i] <= v[j] * p) {
  14. if (maxnum < i - j + 1) maxnum = i - j + 1;
  15. }
  16. }
  17. }
  18. printf ("%d", maxnum);
  19. return 0;
  20. }