123112024-12-11 20:24:33helloworldDarabolás (50 pont)cpp17Time limit exceeded 0/50289ms548 KiB
#include <iostream>
#include <fstream>
#include <bits/stdc++.h>
using namespace std;
int main()
{
    unsigned n, m;
    ifstream f("bemenet.in");
    f >> n >> m;
    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];
    }
    std::sort(vizszintes, vizszintes+n-1, greater<int>());
    std::sort(fuggoleges, fuggoleges+m-1, greater<int>());
    unsigned ossz=0;
    unsigned szamol_f=1, szamol_v=1;
    unsigned index_f=0, index_v=0;
    while(index_f!=m-1 && index_v!=n-1){
        if(vizszintes[index_v]>=fuggoleges[index_f] || index_f>n-1){
            ossz+=vizszintes[index_v]*szamol_v;
            szamol_f++;
            index_v++;
        }
        if(vizszintes[index_v]<fuggoleges[index_f] || index_v>m-1){
            ossz+=fuggoleges[index_f]*szamol_f;
            szamol_v++;
            index_f++;
        }
    }
    while(index_v<n-1) {
        ossz += vizszintes[index_v] * szamol_v;
        index_v++;
    }
    while (index_f<m-1){
        ossz+=fuggoleges[index_f]*szamol_f;
        index_f++;
    }
    ofstream g("kimenet.out");
    g<<ossz;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base0/50
1Time limit exceeded0/0282ms320 KiB
2Time limit exceeded0/0282ms320 KiB
3Time limit exceeded0/1282ms508 KiB
4Time limit exceeded0/1282ms508 KiB
5Time limit exceeded0/1284ms512 KiB
6Time limit exceeded0/1284ms508 KiB
7Time limit exceeded0/1284ms508 KiB
8Time limit exceeded0/1284ms512 KiB
9Time limit exceeded0/1289ms320 KiB
10Time limit exceeded0/1289ms320 KiB
11Time limit exceeded0/1289ms412 KiB
12Time limit exceeded0/1289ms528 KiB
13Time limit exceeded0/1282ms508 KiB
14Time limit exceeded0/1282ms320 KiB
15Time limit exceeded0/1282ms320 KiB
16Time limit exceeded0/1282ms320 KiB
17Time limit exceeded0/1273ms500 KiB
18Time limit exceeded0/1275ms508 KiB
19Time limit exceeded0/2275ms320 KiB
20Time limit exceeded0/2273ms320 KiB
21Time limit exceeded0/3264ms508 KiB
22Time limit exceeded0/3266ms320 KiB
23Time limit exceeded0/4266ms320 KiB
24Time limit exceeded0/4266ms320 KiB
25Time limit exceeded0/4275ms512 KiB
26Time limit exceeded0/4277ms548 KiB
27Time limit exceeded0/4272ms500 KiB
28Time limit exceeded0/4273ms320 KiB