122392024-12-10 12:54:20horichdominik2Virágos rét (50 pont)cpp17Time limit exceeded 18/50300ms808 KiB
#include <iostream>
#include <vector>
using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    
    vector<int> p(n);
    for (int i = 0; i < n; i++) {
        cin >> p[i];
    }

    int utakSzama = 0;
    int elozoStart = 0;
    bool kesz = false;

    while (!kesz) {
        int start = 0;
        int megjartRetek = 0;

        for (int i = elozoStart + 1; i < n; i++) {
            if (p[i] == 1) {
                start = i;
                break;
            }
        }

        if (elozoStart > start) break;

        for (int i = start; i < n; i++) {
            if (p[i] == 1) {
                megjartRetek++;
            }
            if (megjartRetek >= k && p[i] == 1) {
                utakSzama++;
            }
        }

        if (elozoStart + 1 == n) {
            kesz = true;
        }

        elozoStart = start;
    }

    cout << utakSzama << endl;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base18/50
1Accepted0/01ms320 KiB
2Accepted0/01ms320 KiB
3Time limit exceeded0/0273ms568 KiB
4Wrong answer0/21ms500 KiB
5Time limit exceeded0/2300ms320 KiB
6Accepted2/21ms320 KiB
7Accepted3/31ms320 KiB
8Accepted3/31ms320 KiB
9Wrong answer0/31ms320 KiB
10Accepted2/21ms320 KiB
11Wrong answer0/32ms508 KiB
12Accepted2/21ms508 KiB
13Accepted3/31ms320 KiB
14Time limit exceeded0/2282ms748 KiB
15Time limit exceeded0/2284ms568 KiB
16Time limit exceeded0/3277ms568 KiB
17Time limit exceeded0/3300ms568 KiB
18Time limit exceeded0/3284ms572 KiB
19Accepted3/371ms808 KiB
20Time limit exceeded0/3282ms568 KiB
21Time limit exceeded0/3289ms568 KiB
22Time limit exceeded0/3298ms572 KiB