116582024-11-04 10:03:48MagyarKendeSZLGDarabolás (50 pont)cpp17Accepted 50/5075ms4524 KiB
#include <array>
#include <iostream>
#include <queue>

using namespace std;
using ll = long long;

int main() {
    cin.tie(0), ios::sync_with_stdio(0);

    ll M, N, Mdb = 1, Ndb = 1;
    cin >> M >> N;

    priority_queue<array<ll, 2>> pq;

    for (int i = 0; i < M - 1; i++) {
        ll x;
        cin >> x;
        pq.push({x, 0});
    }

    for (int i = 0; i < N - 1; i++) {
        ll x;
        cin >> x;
        pq.push({x, 1});
    }

    ll result = 0;
    while (!pq.empty()) {
        auto [value, axis] = pq.top();
        pq.pop();
        if (axis) {
            result += value * Mdb;
            Ndb++;
        } else {
            result += value * Ndb;
            Mdb++;
        }
    }

    cout << result << "\n";
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/01ms320 KiB
2Accepted0/037ms2480 KiB
3Accepted1/11ms320 KiB
4Accepted1/11ms508 KiB
5Accepted1/11ms320 KiB
6Accepted1/11ms320 KiB
7Accepted1/11ms420 KiB
8Accepted1/11ms508 KiB
9Accepted1/11ms320 KiB
10Accepted1/11ms320 KiB
11Accepted1/11ms320 KiB
12Accepted1/11ms320 KiB
13Accepted1/11ms320 KiB
14Accepted1/11ms320 KiB
15Accepted1/11ms320 KiB
16Accepted1/11ms376 KiB
17Accepted1/11ms320 KiB
18Accepted1/11ms500 KiB
19Accepted2/22ms320 KiB
20Accepted2/22ms320 KiB
21Accepted3/34ms824 KiB
22Accepted3/38ms952 KiB
23Accepted4/418ms1508 KiB
24Accepted4/418ms1388 KiB
25Accepted4/437ms2476 KiB
26Accepted4/437ms2544 KiB
27Accepted4/474ms4524 KiB
28Accepted4/475ms4428 KiB