# 小马哥和数列

Time Limit: 8000/4000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)

Total Submission(s): 1468    Accepted Submission(s): 245

Problem Description

Input

Output

Sample Input

```10 3
1 2 4 3 10 9 8 7 6 5```

Sample Output

```7#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<iostream>
using namespace std;
typedef long long int ll;
ll num[100005];
int main(){
ll n,p;
while(~scanf("%lld%lld",&n,&p)){
for(int i=0;i<n;i++)
scanf("%lld",&num[i]);
sort(num,num+n);
ll maxn=n-1;
ll minn=0;
ll ans=0;
while(1){
if(num[minn]*p>=num[maxn]){
ans=maxn-minn;
maxn--;
minn--;
break;
}
else{
minn++;
if(minn==maxn)
break;
}
}
while(maxn>=ans){
if(num[minn-1]*p>=num[maxn]&&minn-1>=0){
ans++;
minn--;
}
minn--;
maxn--;
}
printf("%lld\n",ans+1);
}
return 0;
}```

494 篇文章45 人订阅

0 条评论

## 相关文章

### HDUOJ---A + B Again

A + B Again Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 ...

296110

### HDUOJ---3743Frosh Week（BIT+离散化）

Frosh Week Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K...

32790

### HDUOJ--------Text Reverse

Text Reverse Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65...

35070

### HDU-1520 Anniversary party（树形DP）

Anniversary party Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/...

29240

### HDU 5676 ztr loves lucky numbers

ztr loves lucky numbers Time Limit: 2000/1000 MS (Java/Others)    Me...

37650

### HDU-----（1083）Courses（最大匹配）

Courses Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 65536/32768 K ...

27470

### CodeForces Roads not only in Berland(并查集)

H - Roads not only in Berland Time Limit:2000MS     Memory Limit:262144KB    ...

26150

### hdu----1686 Oulipo (ac自动机)

Oulipo Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Ja...

40680

### hdu 4315 Climbing the Hill（阶梯博弈转nim博弈）

Climbing the Hill Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/...

366110

### POJ--Strange Way to Express Integers

Strange Way to Express Integers Time Limit: 1000MS Memory Limit: 131072K ...

28370