Pagini recente » Cod sursa (job #1323756) | Cod sursa (job #900923) | Cod sursa (job #2456466) | Cod sursa (job #2391332) | Cod sursa (job #3287927)
#include <bits/stdc++.h>
using namespace std;
ifstream in("branza.in");
ofstream out("branza.out");
deque<pair<int,int>> q;
int n,s,t,i;
int x,y,sm;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
in>>n>>s>>t;
for(i=1;i<=n;++i)
{
in>>x>>y;
while(!q.empty()&& q.front().second<i-t)
q.pop_front();
while(!q.empty() && q.back().first+s*(i-q.back().second)>=x)
q.pop_back();
q.push_back({x,i});
sm+=y*(q.front().first+s*(i-q.front().second));
}
out<<sm;
}