题目是选出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; }
Codeforces Round #244 (Div. 2) B. Prison Transfer,布布扣,bubuko.com
Codeforces Round #244 (Div. 2) B. Prison Transfer
原文:http://www.cnblogs.com/xiongqiangcs/p/3705464.html