Rezultati

Up. imeNalogaJezikRezultatČas oddaje
Aquasonic-2018 Arbitraža C++ 100/100OK 13. okt '18 @ 13:36

Test Točke Porabljen spomin Porabljen čas Status
#1 11/11 3,023 MiB 0,000 s OK
#2 11/11 6,008 MiB 0,110 s OK
#3 11/11 4,645 MiB 0,033 s OK
#4 11/11 4,109 MiB 0,033 s OK
#5 11/11 4,117 MiB 0,057 s OK
#6 11/11 6,012 MiB 0,063 s OK
#7 11/11 6,285 MiB 0,069 s OK
#8 11/11 3,063 MiB 0,000 s OK
#9 12/12 3,066 MiB 0,000 s OK

Ocenjevani program (main.cpp):
#include <bits/stdc++.h>

#define f first
#define s second
#define pb push_back

using namespace std;

typedef long long ll;

const int maxn = 1e5 + 17;

int N, M, K;
vector<int> p, s;


ll ans = 0;
ll psum[maxn], ssum[maxn];
ll prsum[maxn];

int main()
{
    ios_base::sync_with_stdio(false);

    cin >> N >> M >> K;
    for (int i = 0; i < N; i++) {
        int x; cin >> x; p.pb(x);
    }
    for (int i = 0; i < M; i++) {
        int x; cin >> x; s.pb(x);
    }

    sort(p.rbegin(), p.rend());
    sort(s.rbegin(), s.rend());

    psum[1] = p[0];
    ssum[1] = s[0];

    for (int i = 1; i < N; i++) psum[1 + i] = psum[i] + p[i];
    for (int i = 1; i < M; i++) ssum[1 + i] = ssum[i] + s[i];

    prsum[1] = 1LL * p[0] * s[0];
    for (int i = 1; i < min(N, M); i++) prsum[1 + i] = prsum[i] + 1LL * p[i] * s[i];

    K = min(K, N + M);
    for (int k = 0; k <= K; k++) {
        int a = k, b = K - k;
        if (a > N || b > M) continue;

        if (a >= b) {
            ans = max(ans, a * (prsum[b] + psum[min(a, N)] - psum[b]));
        } else {
            ans = max(ans, b * (prsum[a] + ssum[min(b, M)] - ssum[a]));
        }
    }

    cout << ans << endl;
    return 0;
}