Cod sursa(job #206513)

Utilizator nusmaibunkeleviprofesor cicalescu nusmaibunkelevi Data 7 septembrie 2008 13:26:15
Problema Branza Scor 30
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.54 kb
#include<stdio.h>

#define NMAX 100000

struct br{int c,q;};

br v[NMAX+1];
long long c[NMAX+1];

int main(){
freopen("branza.in","r",stdin);
freopen("branza.out","w",stdout);
int n,s,t,i,j,li;
int cmin,ce;
long long total;
scanf("%d%d%d",&n,&s,&t);
for(i=1;i<=n;++i) scanf("%d%d",&v[i].c,&v[i].q);
for(i=1;i<=n;++i){
	cmin=v[i].c;
	li=i-t;
	if(li<1) li=1;
	for(j=li;j<i;++j){
		ce=v[j].c+(i-j)*s;
		if(ce<cmin) cmin=ce;
		}
	c[i]=cmin;
	}
total=0L;
for(i=1;i<=n;++i) total+=c[i]*v[i].q;
printf("%lld",total);
return 0;
}