1030. Perfect Sequence (25) time limit MS Memory limit 65536 KB code length limit 8000 B procedure StandardAuthor Cao, Peng
Given a positive integer sequence, and a positive integer p, the maximum value in this sequence is m, the minimum is m, and if M <= m * p, then this sequence is called the perfect sequence.
Now given the parameter p and some positive integers, you can choose as many numbers as possible to make a perfect sequence.
Input format:
Enter the first line to give two positive integers n and p, where N (<= 105) is the number of positive integers entered, and P (<= 109) is the given parameter. The second line gives n positive integers, each with a number not exceeding 109.
Output format:
You can select the maximum number of rows in a row to make a perfect sequence.
Input Sample:
10 82 3 20 4 5 1 6 7 8 9
Sample output:
8
Reminder: Do not say to the original sequence of the series, so you can first sort
1#include <bits/stdc++.h>2 using namespacestd;3 intMain ()4 {5 intn,maxx=0;6 Doublep,a[100010];7Cin>>n>>p;8 for(intI=0; i<n; i++)9Cin>>A[i];TenSort (a,a+n); One for(intI=0; i<n; i++) A { - for(intj=i+maxx-1; j<n; J + +) - { the if(a[i]*p<A[j]) - Break; - if(j-i+1>Maxx) -maxx=j-i+1; + } - } +cout<<maxx<<Endl; A return 0; at}
Pat-B-1030. Perfect sequence (+)