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;
}
原文地址:https://www.cnblogs.com/xiongqiangcs/p/3705464.html