Cod sursa(job #962285)
| Utilizator | Data | 14 iunie 2013 14:45:26 | |
|---|---|---|---|
| Problema | Branza | Scor | 0 |
| Compilator | c | Status | done |
| Runda | Arhiva de probleme | Marime | 0.49 kb |
#include <stdio.h>
int a[100000],b[100000];
int main()
{
FILE *in,*out;
int jos=0,sus=-1,n,s,t,i;
long long rez=0;
in=fopen("branza.in","r");
out=fopen("branza.out","w");
fscanf(in,"%d%d%d",&n,&s,&t);
for(i=0;i<n;i++)
{
fscanf(in,"%d%d",&a[++sus],&b[i]);
while(i-jos+1>t) jos++;
while(a[sus]<a[jos]) jos++;
sus=jos;
rez+=b[i]*a[jos];
a[jos]+=s;
}
fprintf(out,"%lld",rez);
return 0;
}
