HDU5806 NanoApe Loves Sequence Ⅱ (BestCoder Round #86 C)二分
分析:大于等于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)二分的更多相关文章
- HDU5805 NanoApe Loves Sequence (BestCoder Round #86 B)前后缀预处理
分析:维护空隙的差,然后预处理前缀最大,后缀最大,扫一遍 #include <cstdio> #include <cstring> #include <cmath> ...
- HDU5806 NanoApe Loves Sequence Ⅱ
NanoApe Loves Sequence Ⅱ Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 262144/131072 K (Ja ...
- hdu-5806 NanoApe Loves Sequence Ⅱ(尺取法)
题目链接: NanoApe Loves Sequence Ⅱ Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 262144/13107 ...
- HDU-5806 NanoApe Loves Sequence Ⅱ(two-pointer或二分)
题目大意:给一个整数序列,统计<k,m>子序列的数目.<k,m>序列是满足第k大的数字不比m小的连续子序列. 题目分析:维护一个不小于m的数的个数的后缀和数组,可以枚举序列起点 ...
- Best Coder #86 1002 NanoApe Loves Sequence
NanoApe Loves Sequence Accepts: 531 Submissions: 2481 Time Limit: 2000/1000 MS (Java/Others) Memory ...
- 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 ( ...
- BestCoder Round #86
A题 Price List 巨水..........水的不敢相信. #include <cstdio> typedef long long LL; int main() { int T; ...
- BestCoder Round #86 解题报告
A.Price List Sol 求和查询 Code #include<cstdio> #include<algorithm> #include<iostream> ...
随机推荐
- unix:///tmp/supervisor.sock no such file
运行supervisorctl时保错, 修改/etc/supervisor/supervisor.conf文件 将file=/var/run/supervisor.sock 修改为/tmp/super ...
- 配置Tomcat的服务端口
- ntelliJ IDEA 14 注册码
user or company nameo license key63625-MQ87K-3SRZ2-8MQYB-6NQZC-2Z8K6
- OneThink实现多图片批量上传功能
OneThink原生系统中的图片上传功能是uploadify.swf插件进行上传的,默认是只能上传一张图片的,但是uploadify.swf是支持多图片批量上传的,那么我们稍加改动就可实现OneThi ...
- Box2d学习
Box2d 学习 . Testbed 项目: Testbed 是 Box2d 源码里包含的一个例子程序.Testbed 封装了界面显示.游戏循环等部分的代码.添加新的例子的时候,只需要关注与 Box ...
- Linux和远程系统同步文件(未完成)
实验环境: 本地主机:192.168.0.1 远程主机:192.168.0.101 1. 使用 scp,把/root/tardir1/achieve2.tar.gz复制到远程主机的root用户的hom ...
- USACO Section 4.2: Drainage Ditches
最大流的模板题 /* ID: yingzho1 LANG: C++ TASK: ditch */ #include <iostream> #include <fstream> ...
- PHP高级特性二之文件处理
PHP中的文件处理也是一个相当重要的模块,这一篇的主要内容就是PHP中文件系统的简介. 文件系统用途 1. 项目处理都离不开文件处理 2. 可以用文件长时间保存数据 3. 建立缓存,在服务器中进行文件 ...
- 自定义View(9)关于onLayout
1,何时被调用 当外层容器组件调用其内部组件的layout(l,r,t,b)时,内部组件的onLayout就被调用.与onMeasure类似. 2,注意 onLayout对ViewGroup及子类才有 ...
- NDK(3)java.lang.UnsatisfiedLinkError: Native method not found解决方法
调用native方法时报错如下 : “java.lang.UnsatisfiedLinkError: Native method not found.... ”: 原因分析: 链接器只看到了在so中 ...