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

int main() {
    speed;

    int N, K, M = 0;
    cin >> N >> K;

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

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

    cout << result;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms2040 KiB
2Accepted0/03ms2168 KiB
3Accepted0/04ms2384 KiB
4Accepted2/23ms2592 KiB
5Accepted2/23ms2648 KiB
6Accepted2/23ms2860 KiB
7Accepted3/33ms3072 KiB
8Accepted3/32ms3112 KiB
9Accepted3/33ms3260 KiB
10Accepted2/22ms3204 KiB
11Accepted3/33ms3192 KiB
12Accepted2/22ms3204 KiB
13Accepted3/33ms3332 KiB
14Accepted2/24ms3424 KiB
15Accepted2/24ms3516 KiB
16Accepted3/34ms3640 KiB
17Accepted3/34ms3628 KiB
18Accepted3/34ms3628 KiB
19Accepted3/34ms3776 KiB
20Accepted3/34ms3900 KiB
21Accepted3/34ms3744 KiB
22Accepted3/34ms3740 KiB