123182024-12-11 23:35:40helloworldDarabolás (50 pont)cpp17Time limit exceeded 0/50296ms516 KiB
#include <iostream>
#include <fstream>
#include <algorithm>
using namespace std;

int main() {
    unsigned n, m;
    ifstream f("bemenet.in");
    f >> n >> m;

    int* vizszintes = new int[n - 1];
    int* fuggoleges = new int[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, vizszintes + n - 1, greater<int>());
    sort(fuggoleges, fuggoleges + m - 1, greater<int>());

    unsigned s = 0, szf = 1, szv = 1;
    unsigned indf = 0, indv = 0;

    while (indf < m - 1 || indv < n - 1) {
        if (indf >= m - 1 || (indv < n - 1 && vizszintes[indv] >= fuggoleges[indf])) {
            s += vizszintes[indv] * szv;
            szf++;
            indv++;
        } else {
            s += fuggoleges[indf] * szf;
            szv++;
            indf++;
        }
    }

    ofstream g("kimenet.out");
    g << s;

    delete[] vizszintes;
    delete[] fuggoleges;

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base0/50
1Time limit exceeded0/0284ms320 KiB
2Time limit exceeded0/0284ms320 KiB
3Time limit exceeded0/1284ms320 KiB
4Time limit exceeded0/1284ms320 KiB
5Time limit exceeded0/1289ms508 KiB
6Time limit exceeded0/1291ms320 KiB
7Time limit exceeded0/1289ms320 KiB
8Time limit exceeded0/1291ms320 KiB
9Time limit exceeded0/1293ms320 KiB
10Time limit exceeded0/1293ms320 KiB
11Time limit exceeded0/1294ms324 KiB
12Time limit exceeded0/1296ms320 KiB
13Time limit exceeded0/1275ms320 KiB
14Time limit exceeded0/1275ms320 KiB
15Time limit exceeded0/1277ms512 KiB
16Time limit exceeded0/1277ms320 KiB
17Time limit exceeded0/1280ms508 KiB
18Time limit exceeded0/1280ms320 KiB
19Time limit exceeded0/2280ms320 KiB
20Time limit exceeded0/2280ms320 KiB
21Time limit exceeded0/3277ms320 KiB
22Time limit exceeded0/3277ms508 KiB
23Time limit exceeded0/4277ms500 KiB
24Time limit exceeded0/4277ms320 KiB
25Time limit exceeded0/4280ms320 KiB
26Time limit exceeded0/4280ms500 KiB
27Time limit exceeded0/4280ms320 KiB
28Time limit exceeded0/4280ms516 KiB