83212024-01-14 17:53:07gyjazminVirágos rét (50 pont)cpp17Accepted 50/5020ms4212 KiB
#include <vector>
#include <iostream>
#include <string>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <queue>
#include <numeric>
using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;
    //vector<int> reteksz;
    int ossz = 0;
    for (int i = 0; i < n; i++) {
        int cv;
        cin >> cv;
        if (cv == 1) {
            ossz++;
            //reteksz.push_back(i + 1);
        }
    }
    int s = ossz - k + 1;
    long long  vsz = 0;
    if (ossz < k) {
        cout << 0 << endl;
    }
    /*else if (s == 0) {
        cout << 1 << endl;
    }*/
    else {
        for (int i = 0; i < s; i++) {
            vsz += s-i;
        }
        cout << vsz << endl;
    }
}

SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1752 KiB
2Accepted0/03ms1912 KiB
3Accepted0/019ms1992 KiB
4Accepted2/23ms2128 KiB
5Accepted2/23ms2336 KiB
6Accepted2/23ms2548 KiB
7Accepted3/33ms2760 KiB
8Accepted3/33ms2876 KiB
9Accepted3/33ms3000 KiB
10Accepted2/23ms3180 KiB
11Accepted3/33ms3396 KiB
12Accepted2/23ms3608 KiB
13Accepted3/33ms3688 KiB
14Accepted2/218ms3816 KiB
15Accepted2/218ms3936 KiB
16Accepted3/319ms4084 KiB
17Accepted3/318ms4080 KiB
18Accepted3/319ms4020 KiB
19Accepted3/319ms4028 KiB
20Accepted3/319ms4152 KiB
21Accepted3/320ms4212 KiB
22Accepted3/319ms4132 KiB