Pagini recente » Cod sursa (job #2118961) | Cod sursa (job #1488793) | Cod sursa (job #1410437) | Cod sursa (job #494901) | Cod sursa (job #586307)
Cod sursa(job #586307)
#include<stdio.h>
#include<algorithm>
using namespace std;
struct casa{bool S;long long T;};
int cmp(casa x,casa y)
{if(x.S!=y.S)
return (x.S<y.S);
else
return (x.T<y.T);}
int cmp2(casa x,casa y)
{if(x.S!=y.S)
return (x.S<y.S);
else
return (x.T>y.T);}
int main()
{int n,NRA,NRB,i;
long long TT=0;
freopen("fabrica.in","r",stdin);
freopen("fabrica.out","w",stdout);
casa v3[5001],v1[50001],v2[50001];
scanf("%d %d %d",&n,&NRA,&NRB);
for(i=1;i<=NRA;i++)
{scanf("%lld",&v1[i].T);
v3[i]=v1[i];}
//for(i=1;i<=NRB;i++)
// scanf("%lld",&v2[i].T);
TT=1;
for(i=1;i<=n;i++)
{sort(v1+1,v1+NRA+1,cmp);
if(v1[1].S==0)
v1[1].S=1;
else
if(v1[1].S==1)
{if(v1[1].T<=TT-1)
{v1[1].T+=v3[1].T;}
else
{TT+=(v1[1].T-TT)+v3[1].T;
v1[1].T+=v3[1].T;}}}
sort(v1+1,v1+NRA+1,cmp2);
if(v1[1].T>TT)
TT=TT+v1[1].T-TT;
printf("%lld %lld",TT,TT);}