Pagini recente » Cod sursa (job #1062636) | Cod sursa (job #1419149) | Cod sursa (job #955369) | Cod sursa (job #86709) | Cod sursa (job #2454061)
#include <bits/stdc++.h>
using namespace std;
int N, S, W;
int cost[100000], kg[100000];
long long ans = 0;
deque <int> d;
int main(){
ifstream in("branza.in");
ofstream out("branza.out");
in >> N >> S >> W;
for(int i = 0; i<N; i++){
in >> cost[i] >> kg[i];
while(!d.empty() && cost[d.back()] + 1LL * (i - d.back()) * S > cost[i]) d.pop_back();
d.push_back(i);
if(i - d.front() > W) d.pop_front();
ans+=(cost[d.front()] + 1LL * (i - d.front()) * S) * kg[i];
}
out << ans;
return 0;
}