114102024-09-13 09:52:50madvirVirágos rét (50 pont)cpp17Wrong answer 42/5019ms504 KiB
#include <iostream>
#include <set>

using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;

    ///1. megoldas
    /*for(int i=0; i<n; i++) {
        cin >> ret[i];
        if(ret[i]==1) {
            vir[s]=i;
            s++;
        }
    }

    int k0=0, st=0, fin=1, card=0;

    while(st<s-k) {
        while(k0<k && fin!=s-1) {
            fin++;
        }
        if(k0!=k) {
            cout << 0;
            st=s;
        }
        else {
            card++;
            card+=s-1-fin;
        }
    }

    cout << card;*/

    int x, ret=0, card=0;

    for(int i=0; i<n; i++) {
        cin >> x;
        if(x==1) ret++;
    }

    if(ret<k) card=0;
    else {
        if(ret==k) card=1;
        else {
            int ki=0;
            for(int i=0; i<ret-k+1; i++) {
                card+=ret-k+1-ki;
                ki++;
            }
        }
    }

    cout<< card;

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base42/50
1Accepted0/03ms360 KiB
2Accepted0/03ms364 KiB
3Accepted0/019ms488 KiB
4Accepted2/23ms364 KiB
5Accepted2/22ms376 KiB
6Accepted2/22ms504 KiB
7Accepted3/33ms384 KiB
8Accepted3/32ms376 KiB
9Accepted3/32ms504 KiB
10Accepted2/22ms504 KiB
11Accepted3/33ms384 KiB
12Accepted2/23ms232 KiB
13Accepted3/33ms360 KiB
14Accepted2/217ms256 KiB
15Wrong answer0/218ms276 KiB
16Accepted3/319ms304 KiB
17Accepted3/318ms256 KiB
18Wrong answer0/319ms360 KiB
19Accepted3/318ms504 KiB
20Accepted3/319ms376 KiB
21Accepted3/319ms488 KiB
22Wrong answer0/319ms376 KiB