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

时间:2014-05-04 12:14:55   收藏:0   阅读:340

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

bubuko.com,布布扣
#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;
}
bubuko.com,布布扣

 

Codeforces Round #244 (Div. 2) B. Prison Transfer,布布扣,bubuko.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!