hdu_5806_NanoApe Loves Sequence Ⅱ(双指针)
题目链接:hdu_5806_NanoApe Loves Sequence Ⅱ
题意:
给你一段数,问你有多少个区间满足第K大的数不小于m
题解:
直接双指针加一下区间就行
#include<cstdio>
#include<algorithm>
#define F(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
typedef long long ll;
const int N=2e5+;
int t,n,k,m;
int a[N];
int main()
{
scanf("%d",&t);
while(t--)
{
scanf("%d%d%d",&n,&m,&k);
F(i,,n)scanf("%d",a+i);
int l=,r=,all=;
ll ans=;
while(r<n)
{
while(r<n&&all<k)
{
r++;
if(a[r]>=m)all++;
}
if(r==n&&all<k)break;
if(all==k)ans+=n-r+;
while(all==k)
{
if(a[l]>=m)all--;
l++;
if(all==k)ans+=n-r+;
}
}
printf("%I64d\n",ans);
}
return ;
}
hdu_5806_NanoApe Loves Sequence Ⅱ(双指针)的更多相关文章
- Hdu 5806 NanoApe Loves Sequence Ⅱ(双指针) (C++,Java)
Hdu 5806 NanoApe Loves Sequence Ⅱ(双指针) Hdu 5806 题意:给出一个数组,求区间第k大的数大于等于m的区间个数 #include<queue> # ...
- 5806 NanoApe Loves Sequence Ⅱ(尺取法)
传送门 NanoApe Loves Sequence Ⅱ Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 262144/131072 K ...
- 5805 NanoApe Loves Sequence(想法题)
传送门 NanoApe Loves Sequence Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/131072 K ( ...
- BC#86 1003NanoApe Loves Sequence Ⅱ[two-pointer]
NanoApe Loves Sequence Ⅱ Accepts: 374 Submissions: 946 Time Limit: 4000/2000 MS (Java/Others) Me ...
- hdu 5273 Dylans loves sequence
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5273 Dylans loves sequence Description Dylans is give ...
- hdu 5273 Dylans loves sequence 逆序数简单递推
Dylans loves sequence Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem ...
- HDU 5806 NanoApe Loves Sequence Ⅱ (模拟)
NanoApe Loves Sequence Ⅱ 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5806 Description NanoApe, t ...
- HDU 5805 NanoApe Loves Sequence (模拟)
NanoApe Loves Sequence 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5805 Description NanoApe, the ...
- hdu_5805_NanoApe Loves Sequence(xjb搞)
题目链接:hdu_5805_NanoApe Loves Sequence 题意: 给你n个数,现在要删一个数,删每个数的概率是一样的,现在问你删一个值后的相邻数绝对值最大差的期望是多少,因为担心精度误 ...
随机推荐
- win7提示Xshell5提示缺少msvcp110.dll解决办法
下载地址: http://www.microsoft.com/zh-CN/download/details.aspx?id=30679 X86和X64的都下载下来,安装好后重启计算机,就OK了
- sql 查看语句的性能
SET STATISTICS TIME:看cpu时间 SET STATISTICS IO:关注scan count(计数)------查询读取的表数量:logical read( 逻辑读)次数
- hbase 无法操作与hadoop的安全模式的原因
最近使用hbase时,运行zookeeper的机子没有正常关闭zookeeper就关机了,导致开机后整个hbase集群无法使用,表现为master的localhost:60010 无法登录,使用hba ...
- ensp实战之防火墙安全转发策略
本次实验用防火墙是USG6000V,拓扑图如下: 步骤一: 按上面配好PC1.2.3以及WWW服务器的IP地址.子网掩码以及网关: 步骤二: 进入防火墙的CLI命令模式下,按一下命令配置: 配置各个接 ...
- android 5.0 -- Palette
Palette用来从图片资源中获取颜色内容. 下面是个对颜色值使用的工具类: public class PaletteUtils { public static int getColorWithDef ...
- KMP算法的java实现
package com.trs.utils; public class KMPStr { /* * 在KMP算法中,最难求的就是next函数,如何理解next函数是一个难题,特别是k=next[k], ...
- 阻塞与非阻塞、同步与异步 I/O模型
I/O模型 Linux 下的五种I/O模型 阻塞I/O(blocking I/O) 非阻塞I/O (nonblocking I/O) I/O复用(select 和poll) (I/O multiple ...
- firebug的调试,console
console.log() console.warn() 警告 console.error() 错误 console.group() 分组 console.grounpEnd() 分组结束 co ...
- c#.net 获取时间日期年月日时分秒格式
今天写代码发现两个比较不错的分享下:1.DateTime.ParseExact很多时候我们获取的时间是数字形式表示的,好比20140127134015.927856,通过这个方法DateTime.Pa ...
- HDU 2514 Another Eight Puzzle(DFS)
题目链接 Problem Description Fill the following 8 circles with digits 1~8,with each number exactly once ...