Codeforces Round #244 (Div. 2) B. Prison Transfer
来源:互联网 发布:linux访问windows共享 编辑:程序博客网 时间:2024/05/22 04:47
The prison of your city has n prisoners. As the prison can't accommodate all of them, the city mayor has decided to transferc of the prisoners to a prison located in another city.
For this reason, he made the n prisoners to stand in a line, with a number written on their chests. The number is the severity of the crime he/she has committed. The greater the number, the more severe his/her crime was.
Then, the mayor told you to choose the c prisoners, who will be transferred to the other prison. He also imposed two conditions. They are,
- The chosen c prisoners has to form a contiguous segment of prisoners.
- Any of the chosen prisoner's crime level should not be greater then t. Because, that will make the prisoner a severe criminal and the mayor doesn't want to take the risk of his running away during the transfer.
Find the number of ways you can choose the c prisoners.
The first line of input will contain three space separated integers n (1 ≤ n ≤ 2·105), t (0 ≤ t ≤ 109) and c (1 ≤ c ≤ n). The next line will contain n space separated integers, the ith integer is the severityith prisoner's crime. The value of crime severities will be non-negative and will not exceed109.
Print a single integer — the number of ways you can choose the c prisoners.
4 3 32 3 1 1
2
1 1 12
0
11 4 22 2 0 7 3 2 2 4 9 1 4
6
求解连续序列的数目,并且其中的数有限制。
#include<iostream>//遍历一遍序列,当遇到不符合条件的数,判断一下是否满足ans累加,如果满足则tmp-m+1,代表当前可以划分为几个模块#include<cstring>#include<cstdio>//注意最后结束的时候也应当判断<span id="transmark"></span>一下#include<cmath>#include<algorithm>#define LL int#define inf 0x3f3f3f3fusing namespace std;LL a[200010];bool bj;int main(){ LL n,m,i,j,k,l,tmp; while(~scanf("%d %d %d",&n,&l,&m)) { for(i=0;i<n;i++) scanf("%d",&a[i]); LL ans=0; tmp=0; for(i=0;i<n;i++) { if(a[i]>l) { if(tmp>=m) ans+=tmp-m+1; tmp=0; } else tmp++; } if(tmp>=m) ans+=tmp-m+1; printf("%d\n",ans); } return 0;}
- Codeforces Round #244 (Div. 2)B Prison Transfer
- Codeforces Round #244 (Div. 2) B. Prison Transfer
- Codeforces 427B Prison Transfer
- [Codeforces] 427B - Prison Transfer
- CodeForces 427B Prison Transfer
- CodeForces 427B Prison Transfer
- CodeForces - 427B Prison Transfer
- codeforces#244_div2_B Prison Transfer 区间统计
- Codeforces Prison Transfer
- codeforces Prison Transfer
- B. Prison Transfer
- B. Prison Transfer
- B. Prison Transfer
- Codeforces Round #131 (Div. 2) A B
- Codeforces Round #134 (Div. 2)B. Airport
- Codeforces Round #170 (Div. 2) problem B
- Codeforces Round #173 (Div. 2) Problem B
- Codeforces Round #181 (Div. 2) B. Coach
- uva 11248 Frequency Hopping (最大流)
- MSP430FR系列未使用引脚处理
- 143. Reorder List
- 杭电2066一个人的旅行(spfa)
- C文件读写函数介绍
- Codeforces Round #244 (Div. 2) B. Prison Transfer
- UVA 10820 Send a Table
- R 文件的应用错误,无法找到资源
- 【C】如何利用telnet进行发送邮件【密】
- hdu4585NavigableSet
- 虚拟机启动提示“内部错误”的解决办法
- Linux写时复制技术
- hdoj 1312 Red and Black
- UIWebView中弹出UIPopoverController