#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string.h>
#include <cmath> using namespace std;
const int maxn=+;
long long a[maxn];
int main()
{
int n,p;
scanf("%d %d",&n,&p);
int minidx=;
for(int i=;i<n;i++){
scanf("%lld",&a[i]);
}
sort(a,a+n);
int cnt=,maxlen=;
for(int i=;i<n;i++){
if(a[i]<=a[minidx]*p){
cnt++;
}
else{
if(cnt>maxlen)
maxlen=cnt;
minidx++;
cnt--;
i--;
}
}
//最后不要忘了还要判断下。。。
if(cnt>maxlen)
maxlen=cnt;
printf("%d\n",maxlen);
return ;
}

1085. Perfect Sequence (25)-水题的更多相关文章

  1. 1085. Perfect Sequence (25) -二分查找

    题目如下: Given a sequence of positive integers and another positive integer p. The sequence is said to ...

  2. 1085 Perfect Sequence (25 分)

    Given a sequence of positive integers and another positive integer p. The sequence is said to be a p ...

  3. PAT Advanced 1085 Perfect Sequence (25) [⼆分,two pointers]

    题目 Given a sequence of positive integers and another positive integer p. The sequence is said to be ...

  4. 1085. Perfect Sequence (25)

    the problem is from PAT,which website is http://pat.zju.edu.cn/contests/pat-a-practise/1085 At first ...

  5. PAT (Advanced Level) 1085. Perfect Sequence (25)

    可以用双指针(尺取法),也可以枚举起点,二分终点. #include<cstdio> #include<cstring> #include<cmath> #incl ...

  6. 【PAT甲级】1085 Perfect Sequence (25 分)

    题意: 输入两个正整数N和P(N<=1e5,P<=1e9),接着输入N个正整数.输出一组数的最大个数使得其中最大的数不超过最小的数P倍. trick: 测试点5会爆int,因为P太大了.. ...

  7. pat1085. Perfect Sequence (25)

    1085. Perfect Sequence (25) 时间限制 300 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CAO, Peng Give ...

  8. 1085 Perfect Sequence (25 分)

    1085 Perfect Sequence (25 分) Given a sequence of positive integers and another positive integer p. T ...

  9. PAT 1085 Perfect Sequence

    PAT 1085 Perfect Sequence 题目: Given a sequence of positive integers and another positive integer p. ...

随机推荐

  1. 【项目 · Wonderland】UML设计

    团队作业---UML设计 Part 0 · 简要目录 Part 1 · 团队分工 Part 2 · UML Part 3 · 工具选择 Part 1 · 团队分工 Part 2 · UML 描述信息: ...

  2. 12.SolrCloud原理

    转载自http://blog.csdn.net/u011026968/article/details/50336709 内容涉及:SolrCloud的基础知识.架构.索引创建和更新.查询.故障恢复.负 ...

  3. bat脚本,备份数据库并压缩

    forfiles /p "D:\DBBackup" /m "*.sql" /d -08 /c "cmd /c del @path"forfi ...

  4. PHP实现微信发红包功能2

    <?php class wxPay { //配置参数信息 const SHANGHUHAO = "1430998xxx";//商户号 const PARTNERKEY = & ...

  5. 各种SQL查询技巧汇总 (转)

    原文地址: https://blog.csdn.net/tim_phper/article/details/54963828 select select * from student; all 查询所 ...

  6. JS强制刷新页面、清除缓存刷新

    清理网站缓存的几种方法 meta方法 <meta http-equiv="pragma" content="no-cache"> <meta ...

  7. Linux命令——文件和目录管理

    Linux命令--文件和目录管理 基本命令 命令ls 作用:显示目录下的文件和文件夹 说明:默认显示当前目录,可跟路径参数 参数:-a,显示隐藏目录 参数:-l,显示文件权限 参数:-d,显示文件最后 ...

  8. oninput和onpropertychange实时监听输入框值的变化

    oninput和onpropertychange实时监听输入框值的变化 传统监听输入框的做法就是使用keyup.keydown.keypress,或者change事件来实现,但keyup.keydow ...

  9. 动态代理实现设置tomcat请求编码

    1)htmlcode: <html> <head> <title>$Title$</title> </head> <body> ...

  10. ASP.NET Response 下载文件

    private void DownLoad(string fileName, string path) { FileInfo fi = new FileInfo(path); if (fi.Exist ...