Rezultati

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

Test Točke Porabljen spomin Porabljen čas Status
#1 11/11 3,188 MiB 0,000 s OK
#2 11/11 6,672 MiB 0,118 s OK
#3 11/11 4,902 MiB 0,044 s OK
#4 11/11 4,227 MiB 0,043 s OK
#5 11/11 4,082 MiB 0,049 s OK
#6 11/11 6,668 MiB 0,044 s OK
#7 11/11 6,672 MiB 0,074 s OK
#8 11/11 3,227 MiB 0,010 s OK
#9 12/12 3,227 MiB 0,004 s OK

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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define INF (1LL << 55)
#define maxn 200111

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

ll p[maxn], s[maxn];

vector<ll> a, b;


int main(){
    ll n, m, k;
    scanf("%lld%lld%lld", &n, &m, &k);
    for(int i = 0; i < n; i++)
        scanf("%lld", p + i);
    
    for(int j = 0; j < m; j++)
        scanf("%lld", s + j);
    
    sort(p, p + n);
    reverse(p, p + n);
    sort(s, s + m);
    reverse(s, s + m);
    
    ll cur = 0;
    for(int i = 0; i < min(k, m); i++){
        b.pb(s[i]);
        cur += s[i];
    }
    
    ll ans = cur * 1LL * b.size();
//    cout << "0: " << ans << endl;
    
   for(int i = 0; i < k; i++){
       if(i >= n)
           break;
       
    //   cout << "ok" << endl;
       
       if(a.size() + b.size() + 1 > k){
           ll val = b.back();
           if(a.size() >= b.size()){
                val *= a[b.size() - 1];
                val -= a[b.size() - 1];
            }
            
           cur -= val;
           b.pop_back();
           
//           cout << val << endl;
        }
        
        
       
        ll add = p[i];
        
     //   cout << p[i] << endl;
       // cout << "bsize  " << b.size()  << "  " << i << endl;
        if(b.size() > i){
            add *= b[i];
            add -= b[i];           
        }
        
        cur += add;        
        a.pb(p[i]);
        
    //    cout << add << endl;
        
        
        
        ll sz = max(a.size(), b.size());
        ans = max(ans, 1LL * sz * cur);
        
        
     //  cout << "ok3" << endl;
        
       
       // cout << i + 1 << "  " << cur << "  " << 1LL *  sz * cur << endl;
        
    }
    printf("%lld", ans);
    
    return 0;
}