Pagini recente » Cod sursa (job #758293) | Cod sursa (job #1824649) | Cod sursa (job #2376181) | Cod sursa (job #96754) | Cod sursa (job #2611439)
#include <iostream>
#include <fstream>
#include <algorithm>
#define Flash ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
ifstream in ("fabrica.in");
ofstream out("fabrica.out");
int n, p1, p2;
long long a1[50005], a2[50005];
bool check1(long long val)
{
int sum=0;
for(int i=1; i<=p1; i++)
sum+=val/a1[i];
if(sum>=n) return true;
return false;
}
int main()
{
in>>n>>p1>>p2;
for(int i=1; i<=p1; i++)
in>>a1[i];
for(int i=1; i<=p2; i++)
in>>a2[i];
sort(a1+1, a1+p1+1);
sort(a2+1, a2+p2+1);
long long st=a1[1], dr=a1[1]*n;
long long rez=0;
while(st<=dr)
{
int mij=(st+dr)/2;
if(check1(mij))
{
rez=mij;
dr=mij-1;
}
else
st=mij+1;
}
out<<rez<<" 0\n";
return 0;
}