123192024-12-12 00:03:19helloworldDarabolás (50 pont)cpp17Time limit exceeded 0/50289ms512 KiB
#include <iostream>
#include <fstream>
#include <algorithm>
using namespace std;
int main() {
    unsigned n, m;
    ifstream f("bemenet.in");
    f >> n >> m;
    unsigned temp = m;
    if (n < m) {
        temp = n;
    }
    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, indf = 0, indv = 0, szf = 1, szv = 1;
    for (unsigned i = 0; i < n + m - 2; i++) {
        if (indf < m - 1 && (indv >= n - 1 || fuggoleges[indf] > vizszintes[indv])) {
            s += fuggoleges[indf] * szf;
            szv++;
            indf++;
        } else if (indv < n - 1) {
            s += vizszintes[indv] * szv;
            szf++;
            indv++;
        }
    }
    ofstream g("kimenet.out");
    g << s;
    delete[] vizszintes;
    delete[] fuggoleges;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base0/50
1Time limit exceeded0/0279ms500 KiB
2Time limit exceeded0/0279ms320 KiB
3Time limit exceeded0/1279ms320 KiB
4Time limit exceeded0/1279ms320 KiB
5Time limit exceeded0/1284ms508 KiB
6Time limit exceeded0/1284ms320 KiB
7Time limit exceeded0/1284ms320 KiB
8Time limit exceeded0/1284ms508 KiB
9Time limit exceeded0/1280ms320 KiB
10Time limit exceeded0/1282ms508 KiB
11Time limit exceeded0/1284ms320 KiB
12Time limit exceeded0/1284ms320 KiB
13Time limit exceeded0/1275ms320 KiB
14Time limit exceeded0/1275ms320 KiB
15Time limit exceeded0/1277ms320 KiB
16Time limit exceeded0/1279ms320 KiB
17Time limit exceeded0/1277ms508 KiB
18Time limit exceeded0/1279ms320 KiB
19Time limit exceeded0/2280ms320 KiB
20Time limit exceeded0/2282ms512 KiB
21Time limit exceeded0/3286ms512 KiB
22Time limit exceeded0/3284ms508 KiB
23Time limit exceeded0/4287ms320 KiB
24Time limit exceeded0/4289ms320 KiB
25Time limit exceeded0/4282ms512 KiB
26Time limit exceeded0/4284ms500 KiB
27Time limit exceeded0/4284ms320 KiB
28Time limit exceeded0/4286ms320 KiB