113722024-08-27 22:49:50kukkermanÚthasználati díj (75 pont)cpp17Accepted 75/7520ms912 KiB
#include <iostream>
#include <vector>
#include <algorithm>

void beolvas(std::istream &be, std::vector<int> &v, int &k) {
    int n;
    be >> n >> k;

    v.resize(n);
    for (auto &x : v) {
        be >> x;
    }
}

void feldolgoz(const std::vector<int> &v, int k) {
    const auto n = static_cast<int>(v.size());

    int dijkoteles_db = 0;
    for (int i = 0; i < n; i++) {
        if (v[i] == 1) {
            dijkoteles_db++;
        }
    }

    unsigned long long utvonal_db = 0;
    const auto max_db = std::min(dijkoteles_db, k);
    for (int db = 2; db <= max_db; db++) {
        utvonal_db += dijkoteles_db - db + 1;
    }

    std::cout << utvonal_db << '\n';
}

int main() {
    std::vector<int> v;
    int k;
    beolvas(std::cin, v, k);

    feldolgoz(v, k);

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base75/75
1Accepted0/02ms360 KiB
2Accepted0/02ms360 KiB
3Accepted0/019ms744 KiB
4Accepted5/53ms384 KiB
5Accepted5/52ms376 KiB
6Accepted5/53ms380 KiB
7Accepted5/52ms376 KiB
8Accepted5/52ms232 KiB
9Accepted5/52ms256 KiB
10Accepted5/52ms360 KiB
11Accepted5/52ms492 KiB
12Accepted5/52ms376 KiB
13Accepted5/52ms376 KiB
14Accepted5/519ms744 KiB
15Accepted5/519ms744 KiB
16Accepted5/520ms912 KiB
17Accepted5/520ms912 KiB
18Accepted5/519ms744 KiB