CodeForces - 427B (模拟题)

Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u

Submit Status

Description

The * of your city has n *ers. As the * can't accommodate all of them, the city mayor has decided to transfer c of the *ers to a * located in another city.

For this reason, he made the n *ers 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 *ers, who will be transferred to the other *. He also imposed two conditions. They are,

  • The chosen c *ers has to form a contiguous segment of *ers.
  • Any of the chosen *er's crime level should not be greater then t. Because, that will make the *er 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 *ers.

Input

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 severity ith *er's crime. The value of crime severities will be non-negative and will not exceed 109.

Output

Print a single integer — the number of ways you can choose the c *ers.

Sample Input

Input
4 3 3
2 3 1 1
Output
2
Input
1 1 1
2
Output
0
Input
11 4 2
2 2 0 7 3 2 2 4 9 1 4
Output
6

Source

模拟题
#include <iostream>
#include <algorithm>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdio.h>
using namespace std;
int a[];
int main()
{
int i,j,n,t,c,flag=,ans=;
scanf("%d%d%d",&n,&t,&c);
for(i=;i<n;i++)
cin>>a[i];
for(i=;i<n;i++)
{
if (a[i]>t)
{
if(flag>=c)
ans=ans+flag-c+;
flag=;
}
else if(a[i]<=t)
flag=flag+;
}
if(flag>=c)
ans=ans+flag-c+;
printf("%d\n",ans);
return ;
}
上一篇:【stanford C++】容器III——Vector类


下一篇:学界 | Yann LeCun新作,中日韩文本分类到底要用哪种编码?