codeforces B. Prison Transfer

题意:输入n,t,c,再输入n个数,然后问有多少个连续区间内的最大值小于等于t;

 1 #include <cstdio>

 2 #include <cstring>

 3 #include <algorithm>

 4 #define maxn 200100

 5 using namespace std;

 6 

 7 int t,n,c;

 8 int a[maxn];

 9 int sum[maxn];

10 

11 int main()

12 {

13     scanf("%d%d%d",&n,&t,&c);

14     memset(sum,0,sizeof(sum));

15     for(int i=1; i<=n; i++)

16     {

17         int x;

18         scanf("%d",&x);

19         if(x<=t)

20         {

21             a[i]=1;

22         }

23         sum[i]=sum[i-1]+a[i];

24     }

25     int ans=0;

26     for(int i=1; i+c-1<=n; i++)

27     {

28         if(sum[i+c-1]-sum[i-1]==c)

29         {

30             ans++;

31         }

32     }

33     printf("%d\n",ans);

34     return 0;

35 }
View Code

 

你可能感兴趣的:(codeforces)