#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. 获取QQ头像接口

    https://q4.qlogo.cn/g?b=qq&nk=QQ号码&s=140

  2. 智能家居 (2)手机一键自配置APP

    说明 本教程主要记录APP端一键自配置功能+TCP/IP通信 0配套使用单片机烧录 /* 文件名称:smartconfig.ino 功能:ESP8266快速配置功能 作者:www.doit.am 日期 ...

  3. [转]用多线程方法实现在MFC/WIN32中调用OpenGL函数并创建OpenGL窗口

    原文链接: 1.用多线程方法实现在MFC/WIN32中调用OpenGL函数并创建OpenGL窗口 2.Windows MFC 两个OpenGL窗口显示与线程RC问题

  4. VC++定义全局变量及extern用法

    基本解释:extern可以置于变量或者函数前,以标示变量或者函数的定义在别的文件中,提示编译器遇到此变量和函数时在其他模块中寻找其定义.此外extern也可用来进行链接指定. 也就是说extern有两 ...

  5. PAT A1004 Counting Leaves (30 分)——树,DFS,BFS

    A family hierarchy is usually presented by a pedigree tree. Your job is to count those family member ...

  6. windows10+Python3.6+Anaconda3+tensorflow1.10.0配置和安装

    windows10+Python3.6+Anaconda3+tensorflow1.10.0# Anaconda3安装自行下载安装,之后dos或Anaconda Prompt终端查看Anaconda3 ...

  7. windows安装wget

    windows安装wget1. 下载wget-1.11.4-1-setup.exehttps://jaist.dl.sourceforge.net/project/gnuwin32/wget/1.11 ...

  8. scrollIntoView()的用法

    scrollIntoView是一个与页面(容器)滚动相关的API(官方解释),该API只有boolean类型的参数能得到良好的支持(firefox 36+都支持),所以在这里只讨论参数Boolean类 ...

  9. grpc & pb 环境配置

    grpc 官方中文文档:http://doc.oschina.net/grpc?t=60140 grpc github仓库:https://github.com/grpc/grpc protobuf ...

  10. day63

    一.环境搭建 1.安装node 去官网下载node安装包 傻瓜式安装 万一安装后终端没有node环境,要进行node环境变量的配置(C:\Program Files\nodejs) 可以通过node提 ...