114112024-09-13 09:55:05madvirHőségriadó (50 pont)cpp17Wrong answer 2/5023ms784 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;*/

    long long 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
base2/50
1Wrong answer0/03ms360 KiB
2Wrong answer0/023ms688 KiB
3Wrong answer0/23ms360 KiB
4Wrong answer0/23ms488 KiB
5Wrong answer0/23ms492 KiB
6Accepted2/23ms504 KiB
7Wrong answer0/23ms512 KiB
8Wrong answer0/43ms632 KiB
9Wrong answer0/410ms632 KiB
10Wrong answer0/413ms504 KiB
11Wrong answer0/414ms628 KiB
12Wrong answer0/413ms760 KiB
13Wrong answer0/418ms540 KiB
14Wrong answer0/44ms360 KiB
15Wrong answer0/420ms632 KiB
16Wrong answer0/420ms784 KiB
17Wrong answer0/420ms764 KiB