201012026-01-01 21:13:33szabelrDarabolás (50 pont)cpp17Runtime error 3/5039ms1272 KiB
// Darabolás.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int m, n;
    cin >> m >> n;
    vector<int> s1(m, 0);
    vector<int> s2(n, 0);
    int s1_sum = 0, s2_sum = 0;
    for (int i = 0; i < m - 1; i++)
    {
        int x;
        cin >> x;
        s1[i] = x;
        s1_sum += x;
    }
    for (int i = 0; i < n - 1; i++)
    {
        int x;
        cin >> x;
        s2[i] = x;
        s2_sum += x;
    }
    sort(s1.rbegin(), s1.rend());
    sort(s2.rbegin(), s2.rend());
    int i = 0, y = 0;
    int sum = 0;
    while (i < s1.size() and y < s2.size())
    {
        if (y>=s2.size() or s1[i] > s2[y])
        {
            sum += s1[i] + s2_sum;
            s1_sum -= s1[i];
            i++;
        }
        else
        {
            sum += s2[i] + s1_sum;
            s2_sum -= s2[i];
            y++;
        }
    }
    cout << sum;
}

// 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
base3/50
1Accepted0/01ms316 KiB
2Runtime error0/021ms820 KiB
3Wrong answer0/11ms500 KiB
4Accepted1/11ms316 KiB
5Wrong answer0/11ms316 KiB
6Wrong answer0/11ms316 KiB
7Wrong answer0/11ms316 KiB
8Wrong answer0/11ms316 KiB
9Accepted1/11ms316 KiB
10Wrong answer0/11ms316 KiB
11Accepted1/11ms316 KiB
12Wrong answer0/11ms316 KiB
13Wrong answer0/11ms316 KiB
14Wrong answer0/11ms388 KiB
15Wrong answer0/11ms316 KiB
16Wrong answer0/11ms316 KiB
17Wrong answer0/11ms316 KiB
18Wrong answer0/12ms316 KiB
19Wrong answer0/22ms316 KiB
20Wrong answer0/21ms316 KiB
21Wrong answer0/33ms316 KiB
22Wrong answer0/34ms496 KiB
23Wrong answer0/410ms644 KiB
24Runtime error0/410ms648 KiB
25Wrong answer0/421ms820 KiB
26Runtime error0/421ms872 KiB
27Wrong answer0/439ms1272 KiB
28Wrong answer0/439ms1076 KiB