Pagini recente » Cod sursa (job #2169282) | Cod sursa (job #823317) | Cod sursa (job #1353315) | Cod sursa (job #1441958) | Cod sursa (job #2728042)
#include <iostream>
#include <fstream>
#include <deque>
using namespace std;
ifstream cit("branza.in");
ofstream afis("brabnza.out");
int main()
{
deque <long long> d;
long long n,s,t;
long long minim=0;
cit>>n>>s>>t;
long long c[n+10], p[n+10];
for(int i=0; i<n; i++)
{
cit>>c[i]>>p[i];
while((!d.empty())&&(c[i]<=c[d.back()]+(i-d.back())*s))
d.pop_back();
while((!d.empty())&&(i-d.front()>t))
d.pop_front();
d.push_back(i);
minim = minim + p[i]*(c[d.front()]+(i-d.front())*s);
}
afis<<minim<<endl;
return 0;
}