分析:大于等于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. Mysql Workbench 学习

    1.安装 http://dev.mysql.com/downloads/tools/workbench/ 选择合适的,下载(以Ubuntu 为例) cd到下载目录,然后sudo dpkg -i wor ...

  2. 模糊查询的like '%$name$%'的sql注入避免

    Ibatis like 查询防止SQL注入的方法 Ibatis like 查询防止SQL注入的方法 mysql: select * from tbl_school where school_name ...

  3. 使用struts taglib导致java.lang.NullPointerException: Module 'null' not found.

    比如说,只要jsp的代码里有<html:....>或者<bean:...>之类的struts标签就会在访问该jsp页面的时候报这个错 最后参考这篇文章,发现原来是因为web.x ...

  4. Hadoop管理员的十个最佳实践

    前言 接触Hadoop有两年的时间了,期间遇到很多的问题,既有经典的NameNode和JobTracker内存溢出故障,也有HDFS存储小文件问题,既有任务调度问题,也有MapReduce性能问题.遇 ...

  5. ES6入门之set和map

    Set ES6提供了新的数据结构Set.它类似于数组,但是成员的值都是唯一的,没有重复的值. Set函数可以接受一个数组(或类似数组的对象)作为参数,用来初始化. // 例一 var set = ne ...

  6. USACO Section 2.2: Party Lamps

    这题有个小技巧, 按一个键两次等于没按,所以如果depsum > 16的话其实不用做深搜到depsum次,而只要16次就可以了. /* ID: yingzho1 LANG: C++ TASK: ...

  7. django中的filter和get的区别 (MultipleObjectsReturned: get() returned more than one Publisher --)(DoesNotExist: Publisher matching query does not exist.)

    上面的例子中`` filter()`` 函数返回一个记录集,这个记录集是一个列表. 相对列表来说,有些时候我们更需要获取单个的对象, `` get()`` 方法就是在此时使用的: >>&g ...

  8. 安装hma master出错 Error: Package: perl-Mail-Sender-0.8.13-2.el5.1.noarch

    You are using the EPEL 5 version of the repo instead of 6, go into your /etc/yum.repos.d/epel.repo f ...

  9. MVC列表页通过CheckBox进行批量选择删除

    1.Html代码,将所有CheckBox包含于删除表单,并且所有列表项的CheckBox使用相同的Name,并且Value设置为数据项主键ID @using (Html.BeginForm(" ...

  10. 如何实现wpf的多国语言

    http://www.cnblogs.com/horan/archive/2012/04/20/wpf-multilanguage.html 4.0版本的locbaml http://michaels ...