Cod sursa(job #2437412)

Utilizator Dobricean_IoanDobricean Ionut Dobricean_Ioan Data 9 iulie 2019 15:19:37
Problema Fabrica Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 1.15 kb
#include <bits/stdc++.h>
 
using namespace std;
 
const int N = 100000 + 7;
int n, a[N], b[N];
 
struct E {
        int time;
        int rep;
};
 
bool operator < (E a, E b) {
        return a.time > b.time;
}
 
priority_queue <E> Q1, Q2;
 
void put(priority_queue <E> Q, int sol[]) {
        for (int i = 1; i <= n; i++) {
                E it = Q.top();
                sol[i] = it.time;
                Q.pop();
                Q.push({it.time + it.rep, it.rep});
        }
}
 
int main()
{
        freopen("fabrica.in","r",stdin);
        freopen("fabrica.out","w",stdout);
 
        int x, y;
        cin >> n >> x >> y;
 
        for (int i = 1; i <= x; i++) {
                int foo;
                cin >> foo;
                Q1.push({foo, foo});
        }
 
        for (int i = 1; i <= y; i++) {
                int bar;
                cin >> bar;
                Q2.push({bar, bar});
        }
 
        put(Q1, a);
        put(Q2, b);
 
        int res = 0;
        for (int i = 1; i <= n; i++) {
                int bar = a[i] + b[n + 1 - i];
                res = max(res, bar);
        }
 
        cout << a[n] << " " << res << "\n";
 
        return 0;
}