196132025-12-17 10:36:23gkataVirágos rét (50 pont)cpp17Accepted 50/5017ms596 KiB
// viragos_ret.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <queue>
#define ll long long

using namespace std;

ll n, k, l, i, a, s;

int main()
{
    cin >> n >> k;
    
    for (i = 1; i <= n; ++i)
    {
        cin >> a;
        if (a) ++l;
    }

    if (l < k) cout << "0";
    else
    {
        s = (l - k + 1) * (l - k + 2) / 2;
        cout << s;
    }
}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: 
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/01ms316 KiB
2Accepted0/01ms316 KiB
3Accepted0/017ms316 KiB
4Accepted2/21ms316 KiB
5Accepted2/21ms316 KiB
6Accepted2/21ms316 KiB
7Accepted3/31ms500 KiB
8Accepted3/32ms316 KiB
9Accepted3/32ms508 KiB
10Accepted2/22ms316 KiB
11Accepted3/32ms508 KiB
12Accepted2/21ms316 KiB
13Accepted3/31ms316 KiB
14Accepted2/216ms400 KiB
15Accepted2/217ms588 KiB
16Accepted3/317ms412 KiB
17Accepted3/317ms404 KiB
18Accepted3/317ms564 KiB
19Accepted3/317ms316 KiB
20Accepted3/317ms404 KiB
21Accepted3/317ms400 KiB
22Accepted3/317ms596 KiB