128452025-01-02 11:42:36PKBÚthasználati díj (75 pont)cpp17Time limit exceeded 65/75289ms644 KiB
#include <bits/stdc++.h>
using namespace std;

int main() {
    int N;
	int K;
    cin >> N >> K;

    vector<int> dijas_varosok;
    for (int i = 0; i < N; i++) {
        int toll;
        cin >> toll;
        if (toll == 1) {
            dijas_varosok.push_back(i);
        }
    }

    int total_routes = 0;

    for (int i = 0; i < dijas_varosok.size(); i++) {
        for (int j = i + 1; j < dijas_varosok.size() && (j - i + 1) <= K; ++j) {
            total_routes++;
        }
    }

    cout << total_routes << endl;
}
SubtaskSumTestVerdictTimeMemory
base65/75
1Accepted0/01ms320 KiB
2Accepted0/01ms320 KiB
3Time limit exceeded0/0289ms468 KiB
4Accepted5/51ms320 KiB
5Accepted5/51ms320 KiB
6Accepted5/51ms320 KiB
7Accepted5/51ms320 KiB
8Accepted5/51ms320 KiB
9Accepted5/51ms320 KiB
10Accepted5/51ms320 KiB
11Accepted5/51ms320 KiB
12Accepted5/51ms320 KiB
13Accepted5/51ms320 KiB
14Accepted5/518ms616 KiB
15Accepted5/520ms644 KiB
16Accepted5/543ms640 KiB
17Time limit exceeded0/5210ms504 KiB
18Time limit exceeded0/5284ms568 KiB