121702024-12-06 12:38:49tamasmarkVirágos rét (50 pont)cpp17Hibás válasz 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
RészfeladatÖsszpontTesztVerdiktIdőMemória
base42/50
1Elfogadva0/01ms320 KiB
2Elfogadva0/01ms320 KiB
3Elfogadva0/018ms568 KiB
4Elfogadva2/21ms320 KiB
5Elfogadva2/21ms320 KiB
6Elfogadva2/21ms320 KiB
7Elfogadva3/31ms512 KiB
8Elfogadva3/31ms320 KiB
9Elfogadva3/31ms320 KiB
10Elfogadva2/21ms320 KiB
11Elfogadva3/31ms320 KiB
12Elfogadva2/21ms320 KiB
13Elfogadva3/31ms320 KiB
14Elfogadva2/218ms1352 KiB
15Hibás válasz0/218ms1500 KiB
16Elfogadva3/318ms1036 KiB
17Elfogadva3/317ms684 KiB
18Hibás válasz0/320ms1504 KiB
19Elfogadva3/317ms412 KiB
20Elfogadva3/319ms1488 KiB
21Elfogadva3/319ms1008 KiB
22Hibás válasz0/319ms1452 KiB