Pagini recente » Cod sursa (job #2175607) | Cod sursa (job #2361216) | Cod sursa (job #544550) | Cod sursa (job #2090780) | Cod sursa (job #2887533)
#include <bits/stdc++.h>
using namespace std;
ifstream f("branza.in");
ofstream g("branza.out");
#define cin f
#define cout g
#define int long long
const int Max = 1e5 + 1;
int n, s, t, ans;
int d[Max], front, back;
int cost_nou(int poz, int i)
{
return d[poz] + (i - poz) * s;
}
int32_t main()
{
cin >> n >> s >> t;
front = 1, back = 0;
for(int i = 1; i <= n; i ++)
{
int cost, cantitate;
cin >> cost >> cantitate;
if(front <= back)
if(cost < cost_nou(front, i))
front = back + 1;
back ++;
d[back] = cost;
ans += cost_nou(front, i) * cantitate;
if(front + t == i)
{
front ++;
for(int j = front + 1; j <= back; j ++)
if(cost_nou(j, i) < cost_nou(front, i))
front = j;
}
}
cout << ans;
return 0;
}