149582025-02-10 09:39:24DhaneHaneDarabolás (50 pont)cpp17Wrong answer 14/5075ms1076 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 = 1; i < n; ++i) {
        cin >> sor[i];
    }
    for (int i = 1; i < m; ++i) {
        cin >> osz[i];
    }

    sort(sor.begin(), sor.end());
    sort(osz.begin(), osz.end());
    int s = 0, o = 0, os = 1, so = 1, db=0;
    for (int i = 0; i < n - 1 + m - 1;++i) {
        if (sor.back()>osz.back()) {
            db += sor.back() * os;
            ++so;
            sor.pop_back();
        }
        else{
            db += osz.back() * so;
            ++os;
            osz.pop_back();
        }
    }
    cout << db;
    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
base14/50
1Accepted0/01ms316 KiB
2Wrong answer0/041ms820 KiB
3Accepted1/11ms316 KiB
4Accepted1/11ms316 KiB
5Accepted1/11ms316 KiB
6Accepted1/11ms316 KiB
7Accepted1/11ms316 KiB
8Accepted1/11ms316 KiB
9Accepted1/11ms388 KiB
10Accepted1/11ms596 KiB
11Accepted1/11ms316 KiB
12Accepted1/11ms404 KiB
13Accepted1/11ms316 KiB
14Accepted1/11ms404 KiB
15Accepted1/11ms408 KiB
16Accepted1/12ms316 KiB
17Wrong answer0/12ms408 KiB
18Wrong answer0/12ms508 KiB
19Wrong answer0/22ms316 KiB
20Wrong answer0/22ms316 KiB
21Wrong answer0/34ms316 KiB
22Wrong answer0/38ms316 KiB
23Wrong answer0/421ms456 KiB
24Wrong answer0/421ms564 KiB
25Wrong answer0/441ms840 KiB
26Wrong answer0/441ms840 KiB
27Wrong answer0/475ms1076 KiB
28Wrong answer0/475ms1076 KiB