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里的HRegion(五)
首先,要区分,HRegion服务器包含两大部分:HLog部分和HRegion部分 HBase里的HRegion服务器 HBase里的HRegion 当表的大小超过设置值的时候,HBase会自动将表划 ...
- Nmap 使用技巧及其攻略
Nmap是一款免费开源的网络发现和安全审计工具,支持Windows和Linux平台,有命令行版本和图形化版本.个人建议去学习 nmap 的命令行版本,因为与图形化版本 zenmap 相比,它提供了更多 ...
- 第二次项目冲刺(Beta版本)2017/12/8
一.任务分布 二.燃尽图 三.站立式会议 1.照片(就要传了) 2.任务安排 四.总结 这次吸收了上次的教训,将任务进行更加详细的分布,分工更加明确,果然效率就高多了,哈哈哈.
- 【Android自动化】测试系统的应用程序安装与卸载性能,判断长时间反复安装对系统的整体性能影响
# -*- coding:utf-8 -*- import sys import os import time import subprocess from uiautomator import de ...
- canvas实例_在线画图工具
fadsfklasdjfklasjdklfjasdlk;fjasd;lfjaskl;dfjal
- datagridview 获取选中行的索引
C# CODE for (int i = 0; i < this.dataGridView1.SelectedRows.Count; i++)//遍历所有选中的行 { this.dataGrid ...
- Docker Java应用日志时间和容器时间不一致
1.在docker容器和系统时间不一致是因为docker容器的原生时区为0时区,而国内系统为东八区. 2.还有容器中运行的java应用打出的日志时间和通过date -R方式获取的容器标准时间有八个小时 ...
- [转]numpy中的np.max 与 np.maximum区别
转自:https://blog.csdn.net/lanchunhui/article/details/52700895
- OpenCV——ORB特征检测与匹配
原文链接:https://mp.weixin.qq.com/s/S4b1OGjRWX1kktefyHAo8A #include <opencv2/opencv.hpp> #include ...
- 让win7变成无线路由(需要用管理员权限打开)最后完善.rar
让win7变成无线路由(需要用管理员权限打开)最后完善.bat @ECHO OFF CLS color 0a netsh wlan show drivers ECHO.★★★★★★★★★★★★★★★★ ...