82902024-01-14 09:49:06MagyarKendeSZLGVirágos rét (50 pont)cpp17Accepted 50/504ms3692 KiB
#include <bits/stdc++.h>
#define speed cin.tie(0); ios::sync_with_stdio(0)
using namespace std;

int N, K, M;
int main() {
    speed;

    cin >> N >> K;
    while (N--) {
        char c; cin >> c;
        M += c == '1';
    }

    long long result = 0;
    for (int i = 0; i < M; i++) {
        int curr = M - (i + K) + 1;
        if (curr > 0) result += curr;
    }

    cout << result;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1888 KiB
2Accepted0/03ms2232 KiB
3Accepted0/04ms2564 KiB
4Accepted2/23ms2568 KiB
5Accepted2/22ms2576 KiB
6Accepted2/23ms2816 KiB
7Accepted3/32ms2900 KiB
8Accepted3/33ms2916 KiB
9Accepted3/33ms3132 KiB
10Accepted2/23ms3148 KiB
11Accepted3/33ms3364 KiB
12Accepted2/22ms3404 KiB
13Accepted3/32ms3472 KiB
14Accepted2/24ms3476 KiB
15Accepted2/24ms3476 KiB
16Accepted3/34ms3480 KiB
17Accepted3/34ms3472 KiB
18Accepted3/34ms3476 KiB
19Accepted3/34ms3540 KiB
20Accepted3/34ms3692 KiB
21Accepted3/34ms3548 KiB
22Accepted3/34ms3544 KiB