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. ...
随机推荐
- DevExpress08、SchedulerControl、DateNavigator、SpreadsheetControl
SchedulerControl 该控件以可视化的效果显示预约或者设定的行程: 该控件预约后的数据存储在SchedulerStorage对象里, 当以拖动形式添加SchedulerControl控件到 ...
- spark的shuffle和原理分析
概述 Shuffle就是对数据进行重组,由于分布式计算的特性和要求,在实现细节上更加繁琐和复杂. 在MapReduce框架,Shuffle是连接Map和Reduce之间的桥梁,Map阶段 ...
- SDOI 2018 R2 游记
一篇真正的“游记”. DAY -3 下午: 今天老师批准了我去省选划水的请假要求. 批准之后感觉学习非常有动力,顺便忽悠别的同学和我一起去,然而wzx是唯一一个表示可以考虑一下的同学,其他同学直接一口 ...
- 【转】如何打开注册表编辑器中存储用户信息的SAM文件?
sam文件怎么打开 (Security Accounts Manager安全帐户管理器)负责SAM数据库的控制和维护.SAM数据库位于注册表HKLM\SAM\SAM下,受到ACL保护,可以使用rege ...
- screen命令使用
screen -S + name:创建一个名字叫做name的会话.在里面执行你想要执行的程序,再用Ctrl+a+d退出,让会话Detached,这样就能保证你的任务在后台一直运行,也不会随着终端的关闭 ...
- JavaScript模块化思想之入门篇
在写正文之前先写一点废话,从我大三下学期正式接触前端到现在,已经六个月了.自己从HTML,CSS,简单的JS验证开始,一点点开始走入前端的世界.越发的感觉前端这一领域散发着无穷的魅力,也许这和我真心喜 ...
- selenium自动化环境搭建(Windows)
参考内容:虫师<selenium2自动化测试实战-基于python语言> 一.selenium介绍 selenium主要用于web应用程序的自动化测试,还支持所有基于web的管理任务自动化 ...
- [转载]FFmpeg中使用libx264进行码率控制
1. X264显式支持的一趟码率控制方法有:ABR, CQP, CRF. 缺省方法是CRF.这三种方式的优先级是ABR > CQP > CRF. if ( bitrate ) ...
- 关于原子哥ENC28J60网络通信模块接收数据代码的一点疑惑
---恢复内容开始--- 这几天做STM32的ENC28J60网络通信模块,自己在原子哥的代码上进行修改测试,,发现一个问题,电脑和板子进行通信的时候总隔一段时间板子就死机了. 使用自己的就不会死机, ...
- 支持向量机通俗导论(理解SVM的三层境界)【非原创】
支持向量机通俗导论(理解SVM的三层境界) 作者:July :致谢:pluskid.白石.JerryLead. 出处:结构之法算法之道blog. 前言 动笔写这个支持向量机(support vecto ...