Codeforces Round #244 (Div. 2) B. Prison Transfer

题目是选出c个连续的囚犯,而且囚犯的级别不能大于t

#include <iostream>
using namespace std;
int main(){
    int n,t,c;
    cin >> n >> t >> c;
    int a,cnt = 0, res =0;;
    for(int i = 0 ; i < n ; ++ i) {
        cin >> a;
        if(a > t ){
            if(cnt > c-1) res+=cnt-c+1;
            cnt = 0;
        }else cnt++;
    }
    if(cnt > c-1) res+=cnt-c+1;
    cout<<res<<endl;
}

 

posted @ 2014-05-03 19:37  OpenSoucre  阅读(332)  评论(2编辑  收藏  举报