Pagini recente » Cod sursa (job #2456767) | Cod sursa (job #1495115) | Cod sursa (job #1592563) | Cod sursa (job #943796) | Cod sursa (job #3188738)
#include <bits/stdc++.h>
#define DIM 100000
//#define int long long
using namespace std;
//ifstream f("in.in");
//ofstream g("out.out");
ifstream f("branza.in");
ofstream g("branza.out");
int n,s,t;
int v[DIM+5];
int x,sol = 0;
deque <int> q;
signed main(){
f>>n>>s>>t;
for(int i=1;i<=n;i++){
f>>v[i]>>x;
while(!q.empty() && q.front() < i-t){
q.pop_front();
}
while(!q.empty() && (i-q.back())*s + v[q.back()] >= v[i]){
q.pop_back();
}
q.push_back(i);
sol += x * ( (i-q.front())*s + v[q.front()] );
}
g<<sol;
return 0;
}