1085. Perfect Sequence (25)-水题
#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)-水题的更多相关文章
- 1085. Perfect Sequence (25) -二分查找
题目如下: Given a sequence of positive integers and another positive integer p. The sequence is said to ...
- 1085 Perfect Sequence (25 分)
Given a sequence of positive integers and another positive integer p. The sequence is said to be a p ...
- 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 ...
- 1085. Perfect Sequence (25)
the problem is from PAT,which website is http://pat.zju.edu.cn/contests/pat-a-practise/1085 At first ...
- PAT (Advanced Level) 1085. Perfect Sequence (25)
可以用双指针(尺取法),也可以枚举起点,二分终点. #include<cstdio> #include<cstring> #include<cmath> #incl ...
- 【PAT甲级】1085 Perfect Sequence (25 分)
题意: 输入两个正整数N和P(N<=1e5,P<=1e9),接着输入N个正整数.输出一组数的最大个数使得其中最大的数不超过最小的数P倍. trick: 测试点5会爆int,因为P太大了.. ...
- pat1085. Perfect Sequence (25)
1085. Perfect Sequence (25) 时间限制 300 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CAO, Peng Give ...
- 1085 Perfect Sequence (25 分)
1085 Perfect Sequence (25 分) Given a sequence of positive integers and another positive integer p. T ...
- PAT 1085 Perfect Sequence
PAT 1085 Perfect Sequence 题目: Given a sequence of positive integers and another positive integer p. ...
随机推荐
- Hadoop HBase概念学习系列之HBase里的客户端和HBase集群建立连接(详细)(十四)
需要遵循以下步骤: 1.客户端和Zookeeper集群建立连接.在这之前客户端需要获得一些信息(可以从HBase配置文件中读取或是直接指定).客户端从Zookeeper集群中读取-ROOT-表的位置信 ...
- word文档重新打开后文档结构错乱
word文档重新打开后文档结构错乱,然后通过如下方法解决了. OFFICE2007及以上. 在打开word的时候左下角会有提示word自动更新文档样式,按esc键取消,然后在大纲模式下任 ...
- 【优质】React的学习资源
React的学习资源 github 地址: https://github.com/LeuisKen/react-collection https://github.com/reactnativecn/ ...
- C++课堂作业_02_PAT1025.反转链表
The 1st classwork of the C++ program 题目:PAT.1025.反转链表 github链接:Click Here mdzz,做完题目的第一感受= = 这道题的题意就是 ...
- 探索C#字符串
一.前言 刚接触C#时,书上说string是一种特殊的引用类型,因此string类型变量在作为参数传递到另一个方法,被修改后原变量的值不会发生变化,当时看得我一脸懵逼,什么叫特殊....后来又听说字符 ...
- FastDFS分布文件系统Java客户端使用
原文链接:http://blog.csdn.net/xyang81/article/details/52847311 Java客户端源代码和jar:链接:http://pan.baidu.com/s/ ...
- tcp尽快尽快了
看的撒积分卡拉斯的放假啊的顺口溜
- Kafka学习之路 (四)Kafka的安装
一.下载 下载地址: http://kafka.apache.org/downloads.html http://mirrors.hust.edu.cn/apache/ 二.安装前提(zookeepe ...
- Jmeter之目录结构
首先得了解一下这些东西,以后才能快速的找到某些配置文件进行修改(举个例子,改配置只是其中之一) 一.bin目录examples: 目录中有CSV样例 jmeter.bat windows的启动文件 ...
- scp 免密登录ssh-copy-id 如何使用非22端口 + rsync 同步远程机器的文件到本地
其中:id_rsa为私钥文件,id_rsa.pub为公钥文件 ssh-copy-id -i ~/.ssh/id_rsa.pub "-p 2122 root@IP " 我的:s ...