題目是選出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; }