125192024-12-21 14:41:45PappMatyasÚthasználati díj (75 pont)cpp17Accepted 75/7518ms516 KiB
#include <iostream>

using namespace std;

int main()
{
    int n, k, v, S = 0, ans = 0;
    cin >> n >> k;
    for(int i = 0; i < n; i++)
    {
        cin >> v;
        if(v == 1)
        {
            S++;
        }
    }
    int small = (S < k ? S:k);
    for(int i = 0; i < small; i++)
    {
        ans += i;
    }
    if(S > k)
    {
        ans += (k - 1)*(S - k);
    }
    cout << ans;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base75/75
1Accepted0/01ms320 KiB
2Accepted0/01ms320 KiB
3Accepted0/018ms320 KiB
4Accepted5/51ms320 KiB
5Accepted5/51ms352 KiB
6Accepted5/51ms320 KiB
7Accepted5/51ms320 KiB
8Accepted5/51ms320 KiB
9Accepted5/51ms372 KiB
10Accepted5/51ms320 KiB
11Accepted5/51ms320 KiB
12Accepted5/51ms516 KiB
13Accepted5/51ms320 KiB
14Accepted5/518ms400 KiB
15Accepted5/518ms320 KiB
16Accepted5/518ms320 KiB
17Accepted5/518ms404 KiB
18Accepted5/518ms500 KiB