Pagini recente » Cod sursa (job #2979688) | Cod sursa (job #2931409) | Cod sursa (job #1113593) | Cod sursa (job #2881152) | Cod sursa (job #2621714)
#include <bits/stdc++.h>
using namespace std;
#define ST first
#define ND second
#define PB push_back
#define MKP make_pair
#define LWBND lower_bound
#define UPBND upper_bound
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define FORS(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) x.begin(),x.end()
#define SZ(x) ((int)(x).size())
#define MOD 1000000007 //998244353
#define MAXN 10005
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<PII> VPII;
const int INF=0x3f3f3f3f;
int n,s,t,ans,x,y;
deque<PII> holder;
int main()
{
freopen("branza.in","r",stdin);
freopen("branza.out","w",stdout);
ios_base::sync_with_stdio(0);
cin.tie(0);
cin>>n>>s>>t;
FOR(i,1,n){
cin>>x>>y;
while(!holder.empty()&&(i-holder.back().ND)*s+holder.back().ST > x)
holder.pop_back();
while(!holder.empty() && (i-holder.front().ND) > t)
holder.pop_front();
holder.push_back({x,i});
ans+= y*s*(i-holder.front().ND) + y*holder.front().ST;
}
cout<<ans;
}