Pagini recente » Cod sursa (job #2469197) | Cod sursa (job #1166210) | Cod sursa (job #2619663) | Cod sursa (job #2288591) | Cod sursa (job #2887840)
# include <fstream>
# include<iostream>
# include <deque>
# include <algorithm>
# define NR 100005
using namespace std;
deque <int> d;
int i,j,n,m,S,T;
int c[NR], p[NR];
long long cost;
int main ()
{
ifstream f("branza.in");
ofstream g("branza.out");
f>>n>>S>>T;
for (i=1; i<=n; ++i)
{
f>>c[i]>>p[i];//costul si productia
while (! d.empty() && 1LL*c[i]<=1LL*c[d.back()]+1LL*S*(i-d.back()))
d.pop_back();
d.push_back(i);
if (d.front()==i-T-1) d.pop_front();
cost+=(1LL*p[i]*c[d.front()]+1LL*S*p[i]*(i-d.front()));
}
g<<cost<<endl;
return 0;
}