Pagini recente » Cod sursa (job #2658314) | Cod sursa (job #9961) | Cod sursa (job #2870119) | Cod sursa (job #2848999) | Cod sursa (job #2514997)
#include <bits/stdc++.h>
using namespace std;
long long n,s,t,cost[100005],suma;pair <long long,long long> zile[100005];
deque <int> chestie;
int main () {
freopen("branza.in","r",stdin);
freopen("branza.out","w",stdout);
scanf("%lld%lld%lld", &n, &s, &t);
for(int i=1;i<=n;++i)
scanf("%lld%lld", &zile[i].first, &zile[i].second);
cost[1]=zile[1].first*zile[1].second;chestie.push_front(1);
for(int i=2;i<=n;++i) {
while(!chestie.empty() && i-chestie.front()>t)
chestie.pop_front();
while(!chestie.empty() && (i-chestie.front())*s*zile[i].second+zile[i].second*zile[chestie.front()].first>zile[i].first*zile[i].second)
chestie.pop_front();
if(chestie.empty())
cost[i]=zile[i].second*zile[i].first,chestie.push_back(i);
else
cost[i]=(i-chestie.front())*s*zile[i].second+zile[i].second*zile[chestie.front()].first,chestie.push_back(i);
}
for(int i=1;i<=n;++i)
suma+=cost[i];
printf("%lld", suma);
return 0;
}