Skip to content

Commit

Permalink
Update 1085. Perfect Sequence (25).cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
liuchuo committed Aug 18, 2022
1 parent e330a34 commit 11b12cc
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions AdvancedLevel_C++/1085. Perfect Sequence (25).cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,28 @@ int main() {
}
cout << result;
return 0;
}

#include <iostream>
#include <algorithm>
#include <stdlib.h>
using namespace std;
int main() {
int n;
long long p;
cin >> n >> p;
if (n == 0) {
cout << n;
return 0;
}
long long int *a = new long long int[n];
for (int i = 0; i < n; i++)
cin >> a[i];
sort(a, a + n);
int result = 1;
for (int i = 0; i < n; i++) {
result = max((int)(upper_bound(a, a+n, a[i] * p) - (a+i)), result);
}
cout << result;
return 0;
}

0 comments on commit 11b12cc

Please sign in to comment.