153042025-02-18 09:42:53tamasnagyDarabolás (50 pont)cpp17Wrong answer 0/5093ms2104 KiB
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
void bevekt(int a[], int n) {
    for (int i = 0; i < n - 1; i++) {
        cin >> a[i];
    }
}
void rendezvekt(int a[], int n) {
    for (int i = 0; i < n - 2; i++) {
        for (int j = i+1; j < n-1; j++) {
            if (a[i] < a[j]) {
                swap(a[i], a[j]);
            }
        }
    }
}
void solve(int a[], int b[], int n, int m) {
    int i = 0, j = 0;
    long long int s = 0;
    while (!(i == n - 1 && j == m - 1)) {
        if (a[i] > b[j]) {
            s += a[i] * (j+1);
            i++;
        }
        else {
            s += b[j] * (i+1);
            j++;
        }
    }
    cout << s;
}
int a[100002];
int b[100002];
int main()
{
    int n, m;
    cin >> n >> m;
    bevekt(a, n);
    bevekt(b, m);
    a[n - 1] = 0;
    b[m - 1] = 0;
    sort(a, a + n - 1, greater<int>());
    sort(b, b + m - 1, greater<int>());
    /*rendezvekt(a, n);
    rendezvekt(b, m);*/
    for (int i = 0; i < n; i++) {
        cout << a[i] << ' ';
    }
    cout << endl;
    for (int i = 0; i < m; i++) {
        cout << b[i] << ' ';
    }
    cout << endl;
    solve(a, b, n, m);
}
SubtaskSumTestVerdictTimeMemory
base0/50
1Wrong answer0/01ms316 KiB
2Wrong answer0/050ms1376 KiB
3Wrong answer0/11ms316 KiB
4Wrong answer0/11ms316 KiB
5Wrong answer0/11ms316 KiB
6Wrong answer0/11ms316 KiB
7Wrong answer0/11ms316 KiB
8Wrong answer0/11ms316 KiB
9Wrong answer0/11ms316 KiB
10Wrong answer0/11ms316 KiB
11Wrong answer0/11ms536 KiB
12Wrong answer0/11ms316 KiB
13Wrong answer0/11ms316 KiB
14Wrong answer0/11ms316 KiB
15Wrong answer0/12ms316 KiB
16Wrong answer0/11ms316 KiB
17Wrong answer0/12ms508 KiB
18Wrong answer0/12ms416 KiB
19Wrong answer0/22ms316 KiB
20Wrong answer0/22ms316 KiB
21Wrong answer0/36ms500 KiB
22Wrong answer0/39ms508 KiB
23Wrong answer0/426ms880 KiB
24Wrong answer0/426ms688 KiB
25Wrong answer0/452ms1332 KiB
26Wrong answer0/450ms1156 KiB
27Wrong answer0/493ms2104 KiB
28Wrong answer0/493ms2012 KiB