135912025-01-08 10:39:33PKBÚthasználati díj (75 pont)cpp17Accepted 75/7518ms572 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/01ms316 KiB
2Accepted0/01ms508 KiB
3Accepted0/017ms316 KiB
4Accepted5/51ms316 KiB
5Accepted5/51ms544 KiB
6Accepted5/51ms572 KiB
7Accepted5/51ms316 KiB
8Accepted5/51ms316 KiB
9Accepted5/51ms508 KiB
10Accepted5/51ms508 KiB
11Accepted5/51ms316 KiB
12Accepted5/51ms508 KiB
13Accepted5/51ms508 KiB
14Accepted5/518ms508 KiB
15Accepted5/517ms396 KiB
16Accepted5/517ms392 KiB
17Accepted5/517ms396 KiB
18Accepted5/517ms404 KiB