149622025-02-10 10:17:40DhaneHaneDarabolás (50 pont)cpp17Accepted 50/5075ms1268 KiB
// darabolas.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int main()
{
    int n, m; cin >> n >> m;
    vector <int> osz(m), sor(n);
    for (int i = 0; i < n-1; ++i) {
        cin >> sor[i];
    }
    for (int i = 0; i < m-1; ++i) {
        cin >> osz[i];
    }
    sort(sor.begin(), sor.end());
    sort(osz.begin(), osz.end());
    long long os = 1, so = 1, kolt=0;
    for (int i = 0; i < n - 1 + m - 1;++i) {
        if (sor.back()>osz.back()) {
            kolt += sor.back() * os;
            ++so;
            sor.pop_back();
        }
        else{
            kolt += osz.back() * so;
            ++os;
            osz.pop_back();
        }
    }
    cout << kolt;
    return 0;
}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: 
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/01ms508 KiB
2Accepted0/041ms820 KiB
3Accepted1/11ms316 KiB
4Accepted1/11ms316 KiB
5Accepted1/11ms508 KiB
6Accepted1/11ms316 KiB
7Accepted1/11ms316 KiB
8Accepted1/11ms376 KiB
9Accepted1/11ms316 KiB
10Accepted1/11ms316 KiB
11Accepted1/11ms316 KiB
12Accepted1/11ms316 KiB
13Accepted1/11ms316 KiB
14Accepted1/11ms316 KiB
15Accepted1/11ms404 KiB
16Accepted1/11ms404 KiB
17Accepted1/12ms508 KiB
18Accepted1/12ms408 KiB
19Accepted2/22ms316 KiB
20Accepted2/22ms508 KiB
21Accepted3/34ms316 KiB
22Accepted3/38ms472 KiB
23Accepted4/421ms564 KiB
24Accepted4/420ms624 KiB
25Accepted4/441ms820 KiB
26Accepted4/441ms836 KiB
27Accepted4/475ms1192 KiB
28Accepted4/475ms1268 KiB