题目链接: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 Ⅱ(双指针)的更多相关文章

  1. Hdu 5806 NanoApe Loves Sequence Ⅱ(双指针) (C++,Java)

    Hdu 5806 NanoApe Loves Sequence Ⅱ(双指针) Hdu 5806 题意:给出一个数组,求区间第k大的数大于等于m的区间个数 #include<queue> # ...

  2. 5806 NanoApe Loves Sequence Ⅱ(尺取法)

    传送门 NanoApe Loves Sequence Ⅱ Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 262144/131072 K ...

  3. 5805 NanoApe Loves Sequence(想法题)

    传送门 NanoApe Loves Sequence Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/131072 K ( ...

  4. BC#86 1003NanoApe Loves Sequence Ⅱ[two-pointer]

    NanoApe Loves Sequence Ⅱ  Accepts: 374  Submissions: 946  Time Limit: 4000/2000 MS (Java/Others)  Me ...

  5. hdu 5273 Dylans loves sequence

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5273 Dylans loves sequence Description Dylans is give ...

  6. hdu 5273 Dylans loves sequence 逆序数简单递推

    Dylans loves sequence Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem ...

  7. HDU 5806 NanoApe Loves Sequence Ⅱ (模拟)

    NanoApe Loves Sequence Ⅱ 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5806 Description NanoApe, t ...

  8. HDU 5805 NanoApe Loves Sequence (模拟)

    NanoApe Loves Sequence 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5805 Description NanoApe, the ...

  9. hdu_5805_NanoApe Loves Sequence(xjb搞)

    题目链接:hdu_5805_NanoApe Loves Sequence 题意: 给你n个数,现在要删一个数,删每个数的概率是一样的,现在问你删一个值后的相邻数绝对值最大差的期望是多少,因为担心精度误 ...

随机推荐

  1. 2.1 Word 插入 smartart、图表

    1.插入-smartart 2.插入后的图表中,左边可键入文字 3.按住TAB可以往后缩进 选中目标按住shift+TAB 可以往前缩进. 1.插入-图表 2.选择形状 3.会成功插入对比图表 以及出 ...

  2. Linux nfs+autofs 环境搭建

    两台服务器环境为centos 6.6 1.安装配置nfs 安装portmap 和  nfs [root@node0 ~]# yum install portmap [root@node0 ~]# yu ...

  3. Convert a byte[] array to readable string format. This makes the "hex" readable!

    /* * Java Bittorrent API as its name indicates is a JAVA API that implements the Bittorrent Protocol ...

  4. archive log

    1.查看归档模式 2.查看归档文件所在位置 3.完全恢复和不完全恢复 完全恢复:找到问题产生的时间点,在时间点之后的数据也能同时保留 不完全恢复:只能恢复到产生问题的那个时间点的数据状态. 4.非归档 ...

  5. MarkDown初遇

    MarkDown初遇 纠结盘桓许久,由于那只胖纸,最终决定再次捡起博客这个东东,记录记录生活中.心灵里的点点滴滴. 寻觅的过程中忽然发现MarkDown这个东东,查了查,学习成本不高,简洁而标准,关键 ...

  6. 未能正确加载“Microsoft.VisualStudio.Editor.Implementation.EditorPackage“提示信息

        在安装过vs2015之后出现未能正确加载“Microsoft.VisualStudio.Editor.Implementation.EditorPackage“提示信息在VS的安装目录下,找到 ...

  7. Memory and Scores

    Memory and Scores 题目链接:http://codeforces.com/contest/712/problem/D dp 因为每轮Memory和Lexa能取的都在[-k,k],也就是 ...

  8. vb.net_一个半成品

    Imports System.Text Imports System.Runtime.InteropServices Public Class Form1 '引用win32api进行枚举窗体句柄操作 ...

  9. 2、FileOutputStream--->文件输出流(向文件写入数据)

    Api介绍 定义 FileOutputStream 用于写入诸如图像数据之类的原始字节的流.要写入字符流,请考虑使用 FileWriter. 构造方法 FileOutputStream(File fi ...

  10. display: inline-block兼容性写法

    display:inline-block;*display:inline;*zoom:1;