122442024-12-10 13:10:49horichdominik2Virágos rét (50 pont)cpp17Time limit exceeded 18/50300ms796 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/01ms500 KiB
3Time limit exceeded0/0280ms568 KiB
4Wrong answer0/21ms324 KiB
5Time limit exceeded0/2300ms320 KiB
6Accepted2/21ms320 KiB
7Accepted3/31ms392 KiB
8Accepted3/31ms508 KiB
9Wrong answer0/31ms320 KiB
10Accepted2/21ms320 KiB
11Wrong answer0/31ms320 KiB
12Accepted2/21ms320 KiB
13Accepted3/31ms320 KiB
14Time limit exceeded0/2300ms748 KiB
15Time limit exceeded0/2298ms796 KiB
16Time limit exceeded0/3282ms568 KiB
17Time limit exceeded0/3300ms568 KiB
18Time limit exceeded0/3280ms572 KiB
19Accepted3/371ms568 KiB
20Time limit exceeded0/3284ms568 KiB
21Time limit exceeded0/3282ms568 KiB
22Time limit exceeded0/3300ms756 KiB