Pagini recente » Cod sursa (job #336673) | Cod sursa (job #265179) | Cod sursa (job #891800) | Borderou de evaluare (job #589037) | Cod sursa (job #2514999)
#include <bits/stdc++.h>
using namespace std;
long long n,s,t,cost[100005],suma;pair <long long,long long> zile[100005];
deque <long long> 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(long long i=2;i<=n;++i) {
while(!chestie.empty() && i-chestie.front()>t)
chestie.pop_front();
while(!chestie.empty() && (i-chestie.back())*s*zile[i].second+zile[i].second*zile[chestie.back()].first>zile[i].first*zile[i].second)
chestie.pop_back();
chestie.push_back(i);
cost[i]=(i-chestie.front())*s*zile[i].second+zile[i].second*zile[chestie.front()].first;
}
for(int i=1;i<=n;++i)
suma+=cost[i];
printf("%lld", suma);
return 0;
}