86242024-01-23 21:04:40CsongiVirágos rét (50 pont)cpp17Accepted 50/5020ms4396 KiB
#include <iostream>
#include <bits/stdc++.h>

using namespace std;

int main()
{
    long long n, k;
    cin >> n >> k;
    bool most;
    long long szam = 0;
    long long bonusz = 0;
    for (int i = 1; i <= n; ++i)
    {
        cin >> most;
        if (most)
        {
            szam++;
        }
    }

    for (int i = 1; i <= szam - k + 1; i++)
    {
        bonusz += i;
    }

    cout << bonusz;

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1896 KiB
2Accepted0/03ms2132 KiB
3Accepted0/020ms2320 KiB
4Accepted2/23ms2708 KiB
5Accepted2/23ms2796 KiB
6Accepted2/23ms2892 KiB
7Accepted3/33ms3104 KiB
8Accepted3/33ms3200 KiB
9Accepted3/33ms3436 KiB
10Accepted2/23ms3528 KiB
11Accepted3/33ms3640 KiB
12Accepted2/23ms3764 KiB
13Accepted3/33ms3748 KiB
14Accepted2/218ms3876 KiB
15Accepted2/218ms4092 KiB
16Accepted3/320ms4180 KiB
17Accepted3/319ms4288 KiB
18Accepted3/320ms4396 KiB
19Accepted3/319ms4300 KiB
20Accepted3/319ms4308 KiB
21Accepted3/320ms4304 KiB
22Accepted3/319ms4304 KiB