106892024-04-09 09:06:26AzukitsuDarabolás (50 pont)cpp17Wrong answer 0/50300ms5104 KiB
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int N, M;
    cin >> M >> N;
    vector<int> sorok(M-1);
    vector<int> oszlopok(N-1);
    for (int i = 0; i < M-1; i++) {
        cin >> sorok[i];
    }
    for (int i = 0; i < N-1; i++) {
        cin >> oszlopok[i];
    }
    sort(oszlopok.begin(), oszlopok.end());
    sort(sorok.begin(), sorok.end());
    //for (auto& r : sorok) cout << r << " ";
    //cout << endl;
    int vizszintesvagasok = 0;
    int fuggolegesvagasok = 0;

    int total_cost = 0;

    while (true) {
        int greatest_in_oszlop = 0;
        if (!oszlopok.empty()) {
            greatest_in_oszlop = oszlopok.back();
        }
        int greatest_in_sor = 0;
        if (!sorok.empty()) {
            greatest_in_sor = sorok.back();
        }
        cout << greatest_in_oszlop << " " << greatest_in_sor << endl;
        if (greatest_in_sor == 0 && greatest_in_oszlop == 0) {
            break;
        }
        if (greatest_in_oszlop > greatest_in_sor) {
            fuggolegesvagasok++;
            total_cost += (vizszintesvagasok + 1) * greatest_in_oszlop;
            oszlopok.pop_back();
        }
        else {
            vizszintesvagasok++;
            total_cost += (fuggolegesvagasok + 1) * greatest_in_sor;
            sorok.pop_back();
        }
    }
    cout << total_cost;
}
SubtaskSumTestVerdictTimeMemory
base0/50
1Wrong answer0/03ms1812 KiB
2Time limit exceeded0/0300ms1852 KiB
3Wrong answer0/14ms2372 KiB
4Wrong answer0/14ms2488 KiB
5Wrong answer0/14ms2660 KiB
6Wrong answer0/17ms3004 KiB
7Wrong answer0/14ms2972 KiB
8Wrong answer0/14ms3000 KiB
9Wrong answer0/14ms3192 KiB
10Wrong answer0/14ms3420 KiB
11Wrong answer0/14ms3612 KiB
12Wrong answer0/14ms3828 KiB
13Wrong answer0/13ms4036 KiB
14Wrong answer0/14ms4120 KiB
15Wrong answer0/16ms4124 KiB
16Wrong answer0/16ms4120 KiB
17Wrong answer0/18ms4128 KiB
18Wrong answer0/16ms4236 KiB
19Wrong answer0/27ms4344 KiB
20Wrong answer0/28ms4304 KiB
21Wrong answer0/327ms4332 KiB
22Wrong answer0/350ms4372 KiB
23Wrong answer0/4141ms4732 KiB
24Wrong answer0/492ms4588 KiB
25Wrong answer0/4192ms5100 KiB
26Wrong answer0/4194ms5104 KiB
27Time limit exceeded0/4275ms4528 KiB
28Time limit exceeded0/4254ms4552 KiB