226032026-01-15 11:58:35PKBÚthasználati díj (75 pont)cpp17Accepted 75/7518ms580 KiB
#include <bits/stdc++.h>
using namespace std;

int main() {

    //ujrairva 2


	int varosok_szama;
	int penz;
	cin >> varosok_szama >> penz;
	int temp;
	int egyes = 0;
	for (int i = 0; i < varosok_szama; i++) {
		cin >> temp;
		if (temp == 1) {
			egyes++;
		}
	}

	int megoldas = 0;

	for (int i = 1; i <= egyes; i++) {
		if (egyes-i  >= penz-1) {
			megoldas+=penz-1;
		}
		else {
			megoldas += egyes-i;
		}
	}


	cout << megoldas;
}
SubtaskSumTestVerdictTimeMemory
base75/75
1Accepted0/01ms504 KiB
2Accepted0/01ms316 KiB
3Accepted0/017ms396 KiB
4Accepted5/51ms316 KiB
5Accepted5/51ms316 KiB
6Accepted5/51ms580 KiB
7Accepted5/51ms316 KiB
8Accepted5/51ms316 KiB
9Accepted5/51ms316 KiB
10Accepted5/51ms328 KiB
11Accepted5/51ms316 KiB
12Accepted5/51ms316 KiB
13Accepted5/51ms316 KiB
14Accepted5/518ms400 KiB
15Accepted5/517ms400 KiB
16Accepted5/518ms508 KiB
17Accepted5/518ms392 KiB
18Accepted5/517ms396 KiB