Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- int n, l, k;
- cin >> n >> l >> k;
- int niza[n];
- int prefix_sum[n];
- for(int i = 0; i < n; i++) {
- cin >> niza[i];
- if(niza[i] < l) {
- niza[i] = 0;
- }
- else {
- niza[i] = 1;
- }
- }
- int sum = 0;
- for(int i = 0; i < n; i++) {
- sum += niza[i];
- prefix_sum[i] = sum;
- }
- int days = 0;
- for(int i = 0; i < n; i++) {
- if(niza[i] == 1) {
- if(i + k < n) {
- int tmp_sum = prefix_sum[i + k] - prefix_sum[i];
- if(tmp_sum == k) {
- days++;
- }
- }
- }
- }
- cout << days << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement