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 ...
随机推荐
- Box of Bricks
Box of Bricks Time Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other) Total ...
- div style设置隐藏多余字, title设置鼠标放上显示出来全部
<div style='overflow: hidden; white-space: nowrap; text-overflow: ellipsis;' title='"+data[j ...
- abstract class 和 interface区别
相同点: 1.都不能被直接实例化,都可以通过继承实现其抽象方法: 不同点: 1.接口支持多继承,抽象类只能由一个父类: 2.接口只能定义行为,抽象类既可以定义行为,又可以提供实现: 3.接口只包含方法 ...
- find tar 压缩第一层目录,用于资料备份。
find *.tar.gz -exec tar zxvf '{}' \;//查找当前目录下的.tar.gz 的文件的 并发送给后面的命令执行find . -maxdepth 1 //查找当前目录下的文 ...
- nm applet disable
http://support.qacafe.com/knowledge-base/how-do-i-prevent-network-manager-from-controlling-an-interf ...
- 【stack】模拟网页浏览 poj 1028
#include<stdio.h> #include<string.h> int main() { ][]; ]; int i,depth; strcpy(s[]," ...
- 从市场运营角度谈Uber中国的第一批用户是怎么来的
声明:这篇文章是从http://www.010lm.com/redian/2016/0312/1206875.html转来的,分享给大家. 1)首先告诉用户Uber是做什么的?即培养用户品牌意识. 我 ...
- GDB调试程序常用命令
1.在xv6 内核中 通过 nm kernel | grep _start 找到kernel的起始地址是0010000c 8010b50c D _binary_entryother_start 801 ...
- cddiv/数组维护
题目连接 看代码: #include <set> #include <map> #include <cmath> #include <queue> #i ...
- 转载 Deep learning:三(Multivariance Linear Regression练习)
前言: 本文主要是来练习多变量线性回归问题(其实本文也就3个变量),参考资料见网页:http://openclassroom.stanford.edu/MainFolder/DocumentPage. ...