113612024-08-26 01:20:38kukkermanOsztozkodás (75 pont)cpp17Wrong answer 33/7559ms884 KiB
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdint>

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

    a.resize(n);
    for (auto &e : a) {
        be >> e;
    }
}

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

    sort(a.begin(), a.end());

    int opt = 0, ossz = 0;
    for (int i = 0; i < k; i++) {
        ossz += a[i];
        opt = std::max(ossz, ossz - opt);
    }

    for (int i = k; i < n; i++) {
        ossz += a[i];
        opt = ossz - opt;
    }

    std::cout << opt << ' ' << ossz - opt << '\n';
}

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

    feldolgoz(a, k);

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base33/75
1Accepted0/02ms360 KiB
2Accepted0/03ms280 KiB
3Accepted2/23ms360 KiB
4Accepted3/33ms512 KiB
5Accepted3/33ms232 KiB
6Wrong answer0/24ms504 KiB
7Wrong answer0/34ms360 KiB
8Wrong answer0/24ms504 KiB
9Wrong answer0/34ms376 KiB
10Wrong answer0/24ms360 KiB
11Wrong answer0/34ms360 KiB
12Wrong answer0/156ms760 KiB
13Wrong answer0/256ms760 KiB
14Wrong answer0/156ms684 KiB
15Wrong answer0/257ms744 KiB
16Accepted1/132ms744 KiB
17Accepted2/241ms744 KiB
18Accepted1/132ms744 KiB
19Accepted2/227ms760 KiB
20Accepted2/226ms744 KiB
21Wrong answer0/346ms760 KiB
22Accepted2/239ms780 KiB
23Wrong answer0/343ms744 KiB
24Wrong answer0/246ms744 KiB
25Wrong answer0/346ms744 KiB
26Wrong answer0/246ms672 KiB
27Wrong answer0/359ms760 KiB
28Wrong answer0/259ms884 KiB
29Wrong answer0/354ms744 KiB
30Accepted3/32ms360 KiB
31Accepted3/32ms360 KiB
32Accepted3/32ms360 KiB
33Accepted3/32ms360 KiB
34Accepted3/32ms504 KiB