NanoApe Loves Sequence Ⅱ
来源:互联网 发布:笔记软件 知乎 编辑:程序博客网 时间:2024/06/05 04:52
链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=5806
题目:NanoApe, the Retired Dog, has returned back to prepare for for the National Higher Education Entrance Examination!
In math class, NanoApe picked up sequences once again. He wrote down a sequence with numbers and a number on the paper.
Now he wants to know the number of continous subsequences of the sequence in such a manner that the -th largest number in the subsequence is no less than .
Note : The length of the subsequence must be no less than .
题意:给一串数字,求所有长度大于k,第k大的数字大于等于m的字串个数
分析:这道题很巧妙的用了前缀和来保存从第一个数字到底n个数字里面大于m的数字的个数,之后再用尺取法遍历,记录结果。
题解:
题目:NanoApe, the Retired Dog, has returned back to prepare for for the National Higher Education Entrance Examination!
In math class, NanoApe picked up sequences once again. He wrote down a sequence with
Now he wants to know the number of continous subsequences of the sequence in such a manner that the
Note : The length of the subsequence must be no less than
题意:给一串数字,求所有长度大于k,第k大的数字大于等于m的字串个数
分析:这道题很巧妙的用了前缀和来保存从第一个数字到底n个数字里面大于m的数字的个数,之后再用尺取法遍历,记录结果。
题解:
#include <iostream>#include <cstdio>#include <cstdlib>#include <algorithm>#include <queue>#include <stack>#include <vector>#include <map>#include <string>#include <cstring>#include <functional>#include <cmath>#include <cctype>#include <cfloat>#include <climits>#include <complex>#include <deque>#include <list>#include <set>#include <utility>using namespace std;int pre[200010];__int64 ans;int n,m,k,temp;int main(){//freopen("in.txt","r",stdin);int T;scanf("%d",&T);while(T--){ans=0;scanf("%d %d %d",&n,&m,&k);for(int i=1;i<=n;i++){scanf("%d",&temp);if(temp>=m)pre[i]=pre[i-1]+1;elsepre[i]=pre[i-1];}int l,r;l=0,r=1;for(;l<n;l++){while(pre[r]-pre[l]<k&&r<=n)r++;if(pre[r]-pre[l]<k)break;ans+=n-r+1;}printf("%I64d\n",ans);}return 0;}
0 0
- NanoApe Loves Sequence Ⅱ
- NanoApe Loves Sequence Ⅱ
- hdoj5805 NanoApe Loves Sequence && hdoj 5806 NanoApe Loves Sequence Ⅱ
- hdu NanoApe Loves Sequence Ⅱ
- HDU5806 NanoApe Loves Sequence Ⅱ
- HDOJ 5806 NanoApe Loves Sequence Ⅱ
- hdu 5806 NanoApe Loves Sequence Ⅱ
- HDU 5806 NanoApe Loves Sequence Ⅱ
- hdu 5806 NanoApe Loves Sequence Ⅱ
- HDU 5806:NanoApe Loves Sequence Ⅱ
- HDU 5806 NanoApe Loves Sequence Ⅱ
- HDU 5806 NanoApe Loves Sequence Ⅱ
- hdoj-5806-NanoApe Loves Sequence Ⅱ
- BC#86.1003(HDOJ5806)NanoApe Loves Sequence Ⅱ
- hdoj5806 NanoApe Loves Sequence Ⅱ(尺取法)
- HDU 5806 - NanoApe Loves Sequence Ⅱ
- HDU 5806 NanoApe Loves Sequence Ⅱ
- HDU 5806 NanoApe Loves Sequence Ⅱ
- maven 设置 打包的 编码
- 单体/巨石/单块应用真有那么可怕吗
- Codeforces 711B Chris and Magic Square
- 独立集成QQ和微信分享的回调冲突问题
- 系统、程序的泛泛理解
- NanoApe Loves Sequence Ⅱ
- Android Studio使用技巧
- 深度学习算法实践12---卷积神经网络(CNN)实现
- JavaScript调试技巧之console.log()详解
- 资源文件操作
- 专门为了面试而学的 Java
- 定时删除旧日志
- WebView Cache 缓存清除
- 基于Flume的美团日志收集系统(一)架构和设计