分析:大于等于m的变成1,否则变成0,预处理前缀和,枚举起点,找到第一个点前缀和大于m即可

   找第一个点可以二分可以尺取

#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long LL;
const int N = 2e5+;
int T,n,m,k,a[N],sum[N];
int main(){
scanf("%d",&T);
while(T--){
scanf("%d%d%d",&n,&m,&k);
for(int i=;i<=n;++i){
scanf("%d",&a[i]);
if(a[i]>=m)a[i]=;
else a[i]=;
}
for(int i=;i<=n;++i)sum[i]=sum[i-]+a[i];
LL ret=;
for(int i=;i<=n;++i){
if(n-i+<k)break;
if(sum[n]-sum[i-]<k)break;
int l=i+k-,r=n;
while(l<r){
int mid=(l+r)>>;
if(sum[mid]-sum[i-]>=k)r=mid;
else l=mid+;
}
int tmp=(l+r)>>;
ret+=(n-tmp+);
}
printf("%I64d\n",ret);
}
return ;
}

HDU5806 NanoApe Loves Sequence Ⅱ (BestCoder Round #86 C)二分的更多相关文章

  1. HDU5805 NanoApe Loves Sequence (BestCoder Round #86 B)前后缀预处理

    分析:维护空隙的差,然后预处理前缀最大,后缀最大,扫一遍 #include <cstdio> #include <cstring> #include <cmath> ...

  2. HDU5806 NanoApe Loves Sequence Ⅱ

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

  3. hdu-5806 NanoApe Loves Sequence Ⅱ(尺取法)

    题目链接: NanoApe Loves Sequence Ⅱ Time Limit: 4000/2000 MS (Java/Others)     Memory Limit: 262144/13107 ...

  4. HDU-5806 NanoApe Loves Sequence Ⅱ(two-pointer或二分)

    题目大意:给一个整数序列,统计<k,m>子序列的数目.<k,m>序列是满足第k大的数字不比m小的连续子序列. 题目分析:维护一个不小于m的数的个数的后缀和数组,可以枚举序列起点 ...

  5. Best Coder #86 1002 NanoApe Loves Sequence

    NanoApe Loves Sequence Accepts: 531 Submissions: 2481 Time Limit: 2000/1000 MS (Java/Others) Memory ...

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

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

  7. 5805 NanoApe Loves Sequence(想法题)

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

  8. BestCoder Round #86

    A题 Price List 巨水..........水的不敢相信. #include <cstdio> typedef long long LL; int main() { int T; ...

  9. BestCoder Round #86 解题报告

    A.Price List Sol 求和查询 Code #include<cstdio> #include<algorithm> #include<iostream> ...

随机推荐

  1. 《jQuery风暴》第2章 必须知道的JavaScript知识

    第2章 必须知道的JavaScript知识 JavaScript是jQuery应用的基础,掌握JavaScript这门语言是使用jQuery的基础条件.本章不会全面细致的讲解JavaScript的全部 ...

  2. 卷积神经网络和CIFAR-10:Yann LeCun专访 Convolutional Nets and CIFAR-10: An Interview with Yann LeCun

    Recently Kaggle hosted a competition on the CIFAR-10 dataset. The CIFAR-10 dataset consists of 60k 3 ...

  3. Maven Project configuration is not up-to-date with pom.xml错误解决方法

    导入一个Maven项目之后发现有一个如下的错误: Project configuration is not up-to-date with pom.xml. Run project configura ...

  4. Vi Usage

    标签: linux 编辑工具 md 快捷键以及常用命令(前面带:的是命令) h -> 左移一个字符 j -> 下移一行 k -> 上移一行 l -> 右移一个字符 w或Shif ...

  5. 【分享】Maven插件的源码下载(SVN)

    偶然的情况下找到了Maven插件源码的网址,现分享下 http://svn.apache.org/repos/asf/maven/plugins/ 可以使用SVN下载,在添加新的资源路径时,把上面的网 ...

  6. poj - 3259 Wormholes (bellman-ford算法求最短路)

    http://poj.org/problem?id=3259 农夫john发现了一些虫洞,虫洞是一种在你到达虫洞之前把你送回目的地的一种方式,FJ的每个农场,由n块土地(编号为1-n),M 条路,和W ...

  7. 《OD学hadoop》第一周0626

    一.磁盘管理 Linux添加新硬盘.分区.格式化.自动挂载 http://lxsym.blog.51cto.com/1364623/321643 给Linux系统新增加一块硬盘 http://www. ...

  8. find-right-interval

    https://leetcode.com/problems/find-right-interval/ Java里面TreeMap或者TreeSet有类似C++的lower_bound或者upper_b ...

  9. CodeForces 378C Maze (DFS)

    题目链接 题意:给一个由“.”组成的联通区域,求再添加k个‘#'以后还是联通区域的方案. 分析:做题的时候犯二了,用DFS,一直搜到边缘,然后从边缘依次往回 回溯,回溯的过程中填充’#‘ 一直填充k个 ...

  10. malloc/free和new/delete的异同

    一.基本概念 malloc/free: 1.函数原型及说明: void *malloc(long NumBytes):该函数分配了NumBytes个字节,并返回了指向这块内存的指针.如果分配失败,则返 ...