241612026-02-05 09:47:49KissCsongor777Darabolás (50 pont)cpp17Wrong answer 14/5076ms1452 KiB
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int n,m,horizontal=1,vertical=1,x,s=0;

    vector<int>h,v;

    cin>>m>>n;

    for(int i=1; i<=m-1; i++)
    {
        cin>>x;
        h.push_back(x);
    }

     for(int i=1; i<=n-1; i++)
    {
        cin>>x;
        v.push_back(x);
    }



    sort(v.begin(),v.end());
    sort(h.begin(),h.end());

    /**vector<int>::iterator it;
    for(it=v.begin(); it!=v.end(); it++)cout<<*it<<" ";
    cout<<endl;
    for(it=h.begin(); it!=h.end(); it++)cout<<*it<<" ";
    cout<<endl;**/

    while(!h.empty() && !v.empty())
    {
        ///cout<<h.back()<<" "<<v.back()<<endl;
        if(h.back()>=v.back())
        {
            s+=(vertical*h.back());
            horizontal++;
            h.pop_back();
        }
        else
        {
            s+=(horizontal*v.back());
            vertical++;
            v.pop_back();
        }
    }

    if(h.empty())
    while(!v.empty())
    {
        s+=(horizontal*v.back());
        vertical++;
        v.pop_back();
    }

    if(v.empty())
    while(!h.empty())
    {
        s+=(vertical*h.back());
        horizontal++;
        h.pop_back();
    }


    cout<<s;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base14/50
1Accepted0/01ms316 KiB
2Wrong answer0/043ms940 KiB
3Accepted1/11ms316 KiB
4Accepted1/11ms500 KiB
5Accepted1/11ms316 KiB
6Accepted1/11ms316 KiB
7Accepted1/11ms316 KiB
8Accepted1/11ms316 KiB
9Accepted1/11ms316 KiB
10Accepted1/11ms332 KiB
11Accepted1/11ms412 KiB
12Accepted1/11ms316 KiB
13Accepted1/11ms316 KiB
14Accepted1/11ms316 KiB
15Accepted1/11ms332 KiB
16Accepted1/11ms316 KiB
17Wrong answer0/12ms508 KiB
18Wrong answer0/12ms408 KiB
19Wrong answer0/22ms412 KiB
20Wrong answer0/22ms508 KiB
21Wrong answer0/34ms456 KiB
22Wrong answer0/38ms316 KiB
23Wrong answer0/421ms820 KiB
24Wrong answer0/421ms724 KiB
25Wrong answer0/443ms976 KiB
26Wrong answer0/443ms1020 KiB
27Wrong answer0/476ms1452 KiB
28Wrong answer0/476ms1316 KiB