Cod sursa(job #335007)

Utilizator PavelRazvanPavel Razvan PavelRazvan Data 28 iulie 2009 13:22:45
Problema Branza Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.59 kb
#include<stdio.h>
#define DIM 100001
struct chese
{
    int c,p;
};
chese a[DIM];
int n,s,t,sum;
int main ()
{
    freopen("branza.in","r",stdin);
    freopen("branza.out","w",stdout);
    int i,j,pret,max;
    scanf("%d%d%d",&n,&s,&t);
    for(i=1;i<=n;++i)
        scanf("%d%d",&a[i].c,&a[i].p);
    for(i=1;i<=n;++i)
    {
        max=2000000;
        for(j=i;j>=i-3 && j>=1;--j)
        {
            pret=a[j].c*a[i].p+a[i].p*s*(i-j);
            if(max>pret)
                max=pret;
        }
        sum+=max;
    }
        
    printf("%d",sum);
    return 0;
}