99362024-03-19 11:00:02VargusVirágos rét (50 pont)cpp17Accepted 50/5020ms5424 KiB
#include <iostream>
#include <queue>
#define ll long long

using namespace std;

int main()
{
    ll n, k, osz = 0, db = 0;
    bool elso;
    cin >> n >> k;
    vector <ll> x(n + 1);
    for (ll i = 1; i <= n; ++i)
    {
        cin >> x[i];
        if (x[i] == 1)
        {
            ++db;
            x[i] = db;
            if (db >= k)
                osz += x[i] - k + 1;
        }
    }
    cout << osz;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1808 KiB
2Accepted0/03ms2064 KiB
3Accepted0/020ms3652 KiB
4Accepted2/23ms2324 KiB
5Accepted2/23ms2424 KiB
6Accepted2/23ms2516 KiB
7Accepted3/33ms2644 KiB
8Accepted3/33ms2852 KiB
9Accepted3/33ms3064 KiB
10Accepted2/23ms3180 KiB
11Accepted3/33ms3284 KiB
12Accepted2/23ms3392 KiB
13Accepted3/33ms3528 KiB
14Accepted2/218ms4844 KiB
15Accepted2/218ms4816 KiB
16Accepted3/320ms4948 KiB
17Accepted3/319ms4904 KiB
18Accepted3/320ms5172 KiB
19Accepted3/319ms5272 KiB
20Accepted3/320ms5356 KiB
21Accepted3/320ms5336 KiB
22Accepted3/319ms5424 KiB