123152024-12-11 23:22:32helloworldDarabolás (50 pont)cpp17Time limit exceeded 0/50286ms512 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];
    }
    std::sort(vizszintes, vizszintes+n-1, greater<int>());
    std::sort(fuggoleges, fuggoleges+m-1, greater<int>());
    unsigned s=0, indf=0,indv=0, szf=1, szv=1;
    while(indf<=temp && indv<=temp){
        if (vizszintes[indv]>=fuggoleges[indf] && indv<temp){
            s+=vizszintes[indv]*szv;
            szf++;
            indv++;
        }
        else if(fuggoleges[indf]>vizszintes[indv] && indf<temp){
            s+=fuggoleges[indf]*szf;
            szv++;
            indf++;
        }
        else if(indv==temp){
            s+=fuggoleges[indf]*szf;
            indf++;
        }
       else if(indf==temp){
            s+=vizszintes[indv]*szv;
            indv++;
        }
    }
    ofstream g("kimenet.out");
    g<<s;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base0/50
1Time limit exceeded0/0286ms320 KiB
2Time limit exceeded0/0286ms320 KiB
3Time limit exceeded0/1286ms320 KiB
4Time limit exceeded0/1286ms320 KiB
5Time limit exceeded0/1280ms320 KiB
6Time limit exceeded0/1280ms320 KiB
7Time limit exceeded0/1280ms500 KiB
8Time limit exceeded0/1280ms508 KiB
9Time limit exceeded0/1268ms512 KiB
10Time limit exceeded0/1268ms500 KiB
11Time limit exceeded0/1268ms320 KiB
12Time limit exceeded0/1268ms320 KiB
13Time limit exceeded0/1282ms320 KiB
14Time limit exceeded0/1282ms320 KiB
15Time limit exceeded0/1282ms320 KiB
16Time limit exceeded0/1282ms500 KiB
17Time limit exceeded0/1282ms508 KiB
18Time limit exceeded0/1279ms496 KiB
19Time limit exceeded0/2280ms320 KiB
20Time limit exceeded0/2282ms500 KiB
21Time limit exceeded0/3280ms320 KiB
22Time limit exceeded0/3282ms320 KiB
23Time limit exceeded0/4282ms320 KiB
24Time limit exceeded0/4282ms320 KiB
25Time limit exceeded0/4275ms508 KiB
26Time limit exceeded0/4277ms320 KiB
27Time limit exceeded0/4277ms320 KiB
28Time limit exceeded0/4279ms320 KiB