HDU 5806 NanoApe Loves Sequence Ⅱ
来源:互联网 发布:珍珠控制台模拟软件 编辑:程序博客网 时间:2024/06/06 06:36
Problem Description
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 withn 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 thek -th largest number in the subsequence is no less than m .
Note : The length of the subsequence must be no less thank .
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
Input
The first line of the input contains an integer T , denoting the number of test cases.
In each test case, the first line of the input contains three integersn,m,k .
The second line of the input containsn integers A1,A2,...,An , denoting the elements of the sequence.
1≤T≤10, 2≤n≤200000, 1≤k≤n/2, 1≤m,Ai≤109
In each test case, the first line of the input contains three integers
The second line of the input contains
Output
For each test case, print a line with one integer, denoting the answer.
Sample Input
17 4 24 2 7 7 6 5 1
Sample Output
18
m是确定的,所有的数就变成了0和1,然后循环一遍就可以了,原来这种方法叫two-pointer,从来都不知道。。
#include<set>#include<map>#include<ctime>#include<cmath>#include<stack>#include<queue>#include<bitset>#include<cstdio>#include<string>#include<cstring>#include<iostream>#include<algorithm>#include<functional>#define rep(i,j,k) for (int i = j; i <= k; i++)#define per(i,j,k) for (int i = j; i >= k; i--)using namespace std;typedef __int64 LL;const int low(int x) { return x&-x; }const double eps = 1e-8;const int INF = 0x7FFFFFFF;const int mod = 1e9 + 7;const int N = 2e5 + 10;int T, n, m, k;int a[N], cnt;int main(){ scanf("%d", &T); while (T--) { scanf("%d%d%d", &n, &m, &k); rep(i, 1, n) scanf("%d", &a[i]); LL ans = cnt = 0; for (int i = 1, j = 1; i + k - 1 <= n; cnt -= a[i++] >= m) { for (; j <= n && (i + k - 1 > j || cnt < k); j++) cnt += a[j] >= m; if (cnt >= k) ans += n - j + 2; } printf("%I64d\n", ans); } return 0;}
0 0
- 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 Ⅱ
- HDU 5806 - NanoApe Loves Sequence Ⅱ
- HDU 5806 NanoApe Loves Sequence Ⅱ
- HDU 5806 NanoApe Loves Sequence Ⅱ
- HDU 5806 NanoApe Loves Sequence
- hdu NanoApe Loves Sequence Ⅱ
- hdoj5805 NanoApe Loves Sequence && hdoj 5806 NanoApe Loves Sequence Ⅱ
- hdu NanoApe Loves Sequence
- hdu NanoApe Loves Sequence
- bestcoder #86 第三题 NanoApe Loves Sequence Ⅱ hdu 5806
- HDU 5806 NanoApe Loves Sequence Ⅱ [尺取法]
- HDU 5806 NanoApe Loves Sequence Ⅱ(尺取法)
- hdu 5806 NanoApe Loves Sequence Ⅱ (尺取法)
- git管理项目 一些使用语句
- 简单hash[或者是哈希思想]
- Maven创建An internal error occurred during: "Retrieving archetypes:". Java heap space
- 剑指Offer: 扑克牌顺子
- 数据结构实验之求二叉树后序遍历和层次遍历 (sdut oj2137)
- HDU 5806 NanoApe Loves Sequence Ⅱ
- 1052. Linked List Sorting (25)-PAT甲级真题
- iOS-沙盒目录结构分析
- angularjs取到 My97DatePicker选中的值
- 1097. Deduplication on a Linked List (25)-PAT甲级真题
- 【Dongle】【Web】订餐系统之总结
- AOJ-722 发红包
- 不让EditText获取用户焦点
- hdu 2121 无固定根的最小树形图