121702024-12-06 12:38:49tamasmarkVirágos rét (50 pont)cpp17Wrong answer 42/5020ms1504 KiB
// viragosret.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <vector>
using namespace std;
int n, i, db,k;
struct adatt
{
    int index, sorszam;
};
int sum;
int main()
{
    
    cin >> n>>k;
    vector<adatt>x;
    for (i = 1; i <= n; ++i)
    {
        int a;
        cin >> a;
        if (a)
        {
            db++;
            x.push_back({ i,db });
        }
    }
    if (k > db)
    {
        cout << 0;
        return 0;
    }
    else
    {
        x.resize(db + 1);
        int a;
        for (i = 0; i <= db; ++i)
        {
             a= i + k;
             if (a > db) break;
            sum += (db - a) + 1;
        }
        cout << sum;
    }
    return 0;
}
/*
10 3
0 1 1 0 0 0 1 1 0 1


*/
// 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
base42/50
1Accepted0/01ms320 KiB
2Accepted0/01ms320 KiB
3Accepted0/018ms568 KiB
4Accepted2/21ms320 KiB
5Accepted2/21ms320 KiB
6Accepted2/21ms320 KiB
7Accepted3/31ms512 KiB
8Accepted3/31ms320 KiB
9Accepted3/31ms320 KiB
10Accepted2/21ms320 KiB
11Accepted3/31ms320 KiB
12Accepted2/21ms320 KiB
13Accepted3/31ms320 KiB
14Accepted2/218ms1352 KiB
15Wrong answer0/218ms1500 KiB
16Accepted3/318ms1036 KiB
17Accepted3/317ms684 KiB
18Wrong answer0/320ms1504 KiB
19Accepted3/317ms412 KiB
20Accepted3/319ms1488 KiB
21Accepted3/319ms1008 KiB
22Wrong answer0/319ms1452 KiB