Pagini recente » Cod sursa (job #2136254) | Cod sursa (job #989293) | Cod sursa (job #2308160) | Cod sursa (job #231781) | Cod sursa (job #1493223)
#include <cstdio>
#include <deque>
#define DIM 10000
char buff[DIM];
int c[100023],poz=0,p[100023],n,s,t;
int st=1,dr=0,deq[100023];
struct str
{
int val;
int pos;
}dq[100023];
void next()
{
++poz;
if(poz>=DIM)
{
poz=0;
fread(buff,1,DIM,stdin);
}
}
int citeste()
{
while((!('0'<=buff[poz]&&buff[poz]<='9')))
{
next();
}
int nr=0;
while('0'<=buff[poz]&&buff[poz]<='9')
{
nr*=10;
nr+=(buff[poz]-'0');
next();
}
return nr;
}
int main()
{
freopen ("branza.in","r",stdin);
freopen ("branza.out","w",stdout);
fread(buff,1,DIM,stdin);
n=citeste();
s=citeste();
t=citeste();
long long sum=0;
for(int i=1;i<=n;i++)
{
c[i]=citeste();
p[i]=citeste();
while(dr>=st&&c[i]<=c[deq[dr]]+s*(i-deq[dr])) dr--;
dr++;
deq[dr]=i;
sum+=(c[deq[st]]+s*(i-deq[st]))*p[i];
}
printf("%lld\n",sum);
}