123162024-12-11 23:25:33helloworldDarabolás (50 pont)cpp17Runtime error 0/5032ms32000 KiB
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
    unsigned n, m;
    ifstream f("bemenet.in");
    f >> n >> m;
    vector<int> vizszintes(n - 1);
    vector<int> fuggoleges(m - 1);
    for (unsigned i = 0; i < n - 1; i++) {
        f >> vizszintes[i];
    }
    for (unsigned i = 0; i < m - 1; i++) {
        f >> fuggoleges[i];
    }
    sort(vizszintes.begin(), vizszintes.end(), greater<int>());
    sort(fuggoleges.begin(), fuggoleges.end(), greater<int>());
    unsigned s = 0, indf = 0, indv = 0, szf = 1, szv = 1;
    while (indf < m - 1 && indv < n - 1) {
        if (vizszintes[indv] >= fuggoleges[indf]) {
            s += vizszintes[indv] * szv;
            szf++;
            indv++;
        } else {
            s += fuggoleges[indf] * szf;
            szv++;
            indf++;
        }
    }
    while (indv < n - 1) {
        s += vizszintes[indv] * szv;
        indv++;
    }
    while (indf < m - 1) {
        s += fuggoleges[indf] * szf;
        indf++;
    }
    ofstream g("kimenet.out");
    g << s;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base0/50
1Runtime error0/032ms32000 KiB
2Runtime error0/028ms32000 KiB
3Runtime error0/127ms32000 KiB
4Runtime error0/132ms32000 KiB
5Runtime error0/127ms32000 KiB
6Runtime error0/132ms32000 KiB
7Runtime error0/132ms32000 KiB
8Runtime error0/132ms32000 KiB
9Runtime error0/132ms32000 KiB
10Runtime error0/132ms32000 KiB
11Runtime error0/128ms32000 KiB
12Runtime error0/132ms32000 KiB
13Runtime error0/132ms32000 KiB
14Runtime error0/127ms32000 KiB
15Runtime error0/132ms32000 KiB
16Runtime error0/126ms32000 KiB
17Runtime error0/132ms32000 KiB
18Runtime error0/127ms32000 KiB
19Runtime error0/232ms32000 KiB
20Runtime error0/226ms32000 KiB
21Runtime error0/327ms32000 KiB
22Runtime error0/332ms32000 KiB
23Runtime error0/432ms32000 KiB
24Runtime error0/432ms32000 KiB
25Runtime error0/432ms32000 KiB
26Runtime error0/426ms32000 KiB
27Runtime error0/432ms32000 KiB
28Runtime error0/432ms32000 KiB