123172024-12-11 23:28:54helloworldDarabolás (50 pont)cpp17Time limit exceeded 0/50289ms764 KiB
#include <iostream>
#include <fstream>
#include <bits/stdc++.h>
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[n - 1];
    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, vizszintes + n - 1, greater<int>());
    sort(fuggoleges, fuggoleges + m - 1, 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
1Time limit exceeded0/0279ms320 KiB
2Time limit exceeded0/0279ms320 KiB
3Time limit exceeded0/1279ms500 KiB
4Time limit exceeded0/1279ms324 KiB
5Time limit exceeded0/1277ms508 KiB
6Time limit exceeded0/1277ms320 KiB
7Time limit exceeded0/1277ms512 KiB
8Time limit exceeded0/1277ms508 KiB
9Time limit exceeded0/1287ms320 KiB
10Time limit exceeded0/1287ms320 KiB
11Time limit exceeded0/1287ms508 KiB
12Time limit exceeded0/1287ms508 KiB
13Time limit exceeded0/1284ms320 KiB
14Time limit exceeded0/1284ms512 KiB
15Time limit exceeded0/1284ms320 KiB
16Time limit exceeded0/1284ms500 KiB
17Time limit exceeded0/1289ms320 KiB
18Time limit exceeded0/1289ms556 KiB
19Time limit exceeded0/2289ms320 KiB
20Time limit exceeded0/2289ms320 KiB
21Time limit exceeded0/3277ms320 KiB
22Time limit exceeded0/3277ms764 KiB
23Time limit exceeded0/4277ms320 KiB
24Time limit exceeded0/4277ms500 KiB
25Time limit exceeded0/4280ms508 KiB
26Time limit exceeded0/4280ms320 KiB
27Time limit exceeded0/4280ms508 KiB
28Time limit exceeded0/4280ms320 KiB