139912025-01-09 14:46:04kerekesbalazsVirágos rét (50 pont)cpp17Accepted 50/5017ms508 KiB
#include <bits/stdc++.h>

using namespace std;

int main()
{
    int  n=0,k=0,h=0;
    cin >>n>>k;
    vector<bool>ret(n);
    for (int i=0;i<n;i++){
        int a;
        cin >> a;
        if (a==1){
            ret[i]=true;
            h+=1;
        }
    }
    if (k>h){
        cout<<0;
    }else{
        long long b=0;
        for (int i=0;h-(k+i)+1!=0;i++){
            b+=h-(k+i)+1;
        }
        cout <<b <<' ';
    }
    return 0;
}
/*
10 3
0 1 1 0 0 0 1 1 0 1
*/
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/01ms316 KiB
2Accepted0/01ms316 KiB
3Accepted0/017ms508 KiB
4Accepted2/21ms316 KiB
5Accepted2/21ms316 KiB
6Accepted2/21ms316 KiB
7Accepted3/31ms508 KiB
8Accepted3/31ms316 KiB
9Accepted3/31ms316 KiB
10Accepted2/21ms316 KiB
11Accepted3/31ms508 KiB
12Accepted2/21ms376 KiB
13Accepted3/31ms316 KiB
14Accepted2/217ms408 KiB
15Accepted2/217ms508 KiB
16Accepted3/317ms316 KiB
17Accepted3/317ms408 KiB
18Accepted3/317ms408 KiB
19Accepted3/317ms316 KiB
20Accepted3/317ms412 KiB
21Accepted3/317ms316 KiB
22Accepted3/317ms412 KiB