139852025-01-09 13:59:09tamasmarkDarabolás (50 pont)cpp17Wrong answer 10/50300ms1844 KiB
// darabolas.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <algorithm>

using namespace std;
struct adat
{
    int ertek, ered;

};
deque<adat>x,y;
int n, m, j, i, sum;

bool hasonlit(adat a, adat b)
{
    if (a.ertek > b.ertek) return 1;
    else return 0;
}
int main()
{
    cin >> n >> m;
    x.resize(n);
    y.resize(m);

    for (i = 1; i < n; ++i)
    {
        cin >> x[i].ered;
        x[i].ertek = x[i].ered;
    }
    for (i = 1; i < m; ++i)
    {
        cin >> y[i].ered;
        y[i].ertek = y[i].ered;
    }
    x.pop_front();
    y.pop_front();
    sort(x.begin() + 1, x.end(),hasonlit);
    sort(y.begin()+1,y.end(),hasonlit);

    while (!x.empty() || !y.empty())
    {

        if (x.front().ertek==y.front().ertek)
        {
            if (x.size() <= y.size())
            {
                sum += x.front().ertek;
                for (auto& e : y)
                    e.ertek += e.ered;
                x.pop_front();
            }
            else
            {
                sum += y.front().ertek;
                for (auto& e : x)
                    e.ertek += e.ered;
                y.pop_front();
            }
        }
        else if (x.front().ertek > y.front().ertek)
        {
            sum += x.front().ertek;
            for (auto& e : y)
                e.ertek += e.ered;
            x.pop_front();
        }
        else
        {
            sum += y.front().ertek;
            for (auto& e : x)
                e.ertek += e.ered;
            y.pop_front();
        }
    }
    cout << sum;
    return 0;
}
/*
4 6
4 1 2
2 1 3 1 4


*/
// 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
base10/50
1Wrong answer0/01ms316 KiB
2Time limit exceeded0/0282ms1076 KiB
3Accepted1/11ms316 KiB
4Accepted1/11ms316 KiB
5Accepted1/12ms316 KiB
6Accepted1/12ms508 KiB
7Accepted1/11ms316 KiB
8Accepted1/11ms316 KiB
9Accepted1/11ms508 KiB
10Accepted1/11ms316 KiB
11Accepted1/11ms316 KiB
12Accepted1/11ms372 KiB
13Wrong answer0/11ms404 KiB
14Wrong answer0/12ms316 KiB
15Wrong answer0/12ms316 KiB
16Wrong answer0/12ms316 KiB
17Wrong answer0/12ms316 KiB
18Wrong answer0/12ms316 KiB
19Wrong answer0/22ms316 KiB
20Wrong answer0/22ms316 KiB
21Wrong answer0/324ms316 KiB
22Wrong answer0/383ms556 KiB
23Time limit exceeded0/4209ms848 KiB
24Time limit exceeded0/4209ms848 KiB
25Time limit exceeded0/4273ms1268 KiB
26Time limit exceeded0/4280ms1076 KiB
27Time limit exceeded0/4300ms1844 KiB
28Time limit exceeded0/4300ms1844 KiB