Pagini recente » Cod sursa (job #1991586) | Cod sursa (job #951647) | Cod sursa (job #1302651) | Cod sursa (job #2144572) | Cod sursa (job #2832937)
#include<fstream>
#include<iostream>
#include<climits>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
//ifstream f("in.in");
//ofstream g("out.out");
ifstream f("branza.in");
ofstream g("branza.out");
int n,dq[100001],v[100001],st=1,dr=0,c,p,s,t;
long long sol;
int main()
{
f>>n>>s>>t;
for(int i=1;i<=n;i++)
{
f>>c>>p;
v[i]=c;
while(st<=dr&&v[dq[dr]]+(i-dq[dr])*s>=c)
dr--;
dr++;
dq[dr]=i;
sol+=((v[dq[st]])+(i-dq[st])*s)*p;
if(i-dq[st]>t)
st++;
}
g<<sol;
f.close();
g.close();
return 0;
}