Cod sursa(job #23733)

Utilizator Anarchy99Vlad Manolache Anarchy99 Data 1 martie 2007 11:46:48
Problema Lapte Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.58 kb
#include<fstream.h>
ifstream f("lapte.in");
ofstream g("lapte.out");
int n,l,a[500][2],x[500],max,t1,t2,y[500];
int citire()
{ int i,aux;
  f>>n>>l;
  for(i=1;i<=n;i++) f>>a[i][0]>>a[i][1];
  return 0;
}
int rez()
{ int i=1,j,r,z,k;
  max=0;
  while(x[max]<l || y[max]<l)
  { max++; r=z=0;
    while(r<max&&z<max)
    {
    for(i=1;i<=n;i++)
    {  if((i%a[i][0])==0) if((r+a[i][0])<=max) r+=a[i][0];
       if((i%a[i][1])==0) if((z+a[i][1])<=max) z+=a[i][1];
    }}
    x[max]=r;
    y[max]=z;
  }
  return 0;
}


int main()
{ citire(); rez(); g<<max; return 0; }