NanoApe Loves Sequence Ⅱ(尺取法)
题目链接:NanoApe Loves Sequence Ⅱ
Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 262144/131072 K (Java/Others)
Total Submission(s): 339 Accepted Submission(s): 165
In math class, NanoApe picked up sequences once again. He wrote down a sequence with n numbers and a number m on the paper.
Now he wants to know the number of continous subsequences of the sequence in such a manner that the k-th largest number in the subsequence is no less than m.
Note : The length of the subsequence must be no less than k.
In each test case, the first line of the input contains three integers n,m,k.
The second line of the input contains n integers A1,A2,...,An, denoting the elements of the sequence.
1≤T≤10, 2≤n≤200000, 1≤k≤n/2, 1≤m,Ai≤109
7 4 2
4 2 7 7 6 5 1
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
const int maxn = ;
int a[maxn];
int prek[maxn];
int main()
{
int T;cin>>T;
while(T--)
{
int n,m,k;
cin>>n>>m>>k;
memset(prek,,sizeof(prek));
for(int i=;i<=n;i++)
{
scanf("%d",&a[i]);
if(a[i]>=m) prek[i] += prek[i-]+;
else prek[i] = prek[i-];
}
long long ans = ;
int sum = ;
int t = ;
for(int l=;l<=n;l++)
{
while(t<=n&&sum<k)
{
sum = prek[t]-prek[l];
t++;
}
if(sum<k) break;
ans += (n-t+);
sum = prek[t-]-prek[l+];
}
printf("%I64d\n",ans);
}
return ;
}
NanoApe Loves Sequence Ⅱ(尺取法)的更多相关文章
- hdu-5806 NanoApe Loves Sequence Ⅱ(尺取法)
题目链接: NanoApe Loves Sequence Ⅱ Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 262144/13107 ...
- HDU5806:NanoApe Loves Sequence Ⅱ(尺取法)
题目链接:HDU5806 题意:找出有多少个区间中第k大数不小于m. 分析:用尺取法可以搞定,CF以前有一道类似的题目. #include<cstdio> using namespace ...
- 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 ( ...
- 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 ...
- Best Coder #86 1002 NanoApe Loves Sequence
NanoApe Loves Sequence Accepts: 531 Submissions: 2481 Time Limit: 2000/1000 MS (Java/Others) Memory ...
- hdu-5805 NanoApe Loves Sequence(线段树+概率期望)
题目链接: NanoApe Loves Sequence Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/131072 ...
- HDU5806 NanoApe Loves Sequence Ⅱ
NanoApe Loves Sequence Ⅱ Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 262144/131072 K (Ja ...
随机推荐
- allocator 类
allcator是一个模板类 定义在memory头文件中,将内存分配与对象构造分开,分配的内存是原始的.未构造的 一.how to use 因其实一个类,则使用allcator时需要首先声明一个类对象 ...
- Autofac 组件、服务、自动装配(2)
一.组件 创建出来的对象需要从组件中来获取,组件的创建有如下4种(延续第一篇的Demo,仅仅变动所贴出的代码)方式: 1.类型创建RegisterType AutoFac能够通过反射检查一个类型,选择 ...
- Bootstrap 3 与 Foundation 5
开发工程师, 使用 Bootstrap. 前端开发人员, 使用 Foundation. 我们来谈谈为什么. Bootstrap 与 Foundation 有许多关键的区别, 但是, 我想你只需要记住一 ...
- ios 中NSArray
// #import <Foundation/Foundation.h> #import "Animal.h" int main(int argc, const cha ...
- svg笔记----------path篇
每个路径都必须以moveto 命令开始 moveto.lineto和closepath <path d="M 10 10 L 100 10z"/> 大写字母命令的坐标是 ...
- 有了SSL证书,如何在IIS环境下部署https?【转载】
昨天各位小伙伴都很开心的领取了自己的SSL证书,但是大部分小伙伴却不知道如何部署,也许是因为第一次接触SSL这种高端的东西吧,不过个人觉得就是懒懒懒...本来小编也挺懒的,但是答应了各位小伙伴的,那么 ...
- linux c中select使用技巧
1.select函数作为定时器使用 it_value.tv_sec = 0; it_value.tv_usec = 100000: select(1,NULL,NULL,NULL,& ...
- textFiled输入字数的控制问题之—把带输入的拼音也判断了
一个textFiled,控制只能输入五个字,现在你已经输入了四个字,在输入第五个字的时候,输入一个拼音之后就不能输入后一个拼音,这里把拼音也当成字来判断了,这种情况下就需要_textFiled.mar ...
- SQL中的左连接与右连接有什么区别,点解返回值会不同?(转)
例子,相信你一看就明白,不需要多说 A表(a1,b1,c1) B表(a2,b2) a1 b1 c1 a2 b2 01 数学 95 01 张三 02 语文 90 02 李四 03 英语 80 04 王五 ...
- 最简单易懂的webService客户端之soap+xml请求
代码准备: 1.网络上有提供一些免费的服务器测试地址,可以上这里找一找:https://my.oschina.net/CraneHe/blog/183471 2.我选择了一个翻译地址:http://w ...