Pagini recente » Cod sursa (job #2691739) | Cod sursa (job #2754996) | Cod sursa (job #2496923) | Cod sursa (job #2755771) | Cod sursa (job #2500012)
#include <fstream>
using namespace std;
ifstream fin("branza.in");
ofstream fout("branza.out");
const int N = 1e5 + 7;
int c[N], dq[N];
int main()
{
long long ans(0);
int n, s, t, p, st(0), dr(-1);
fin >> n >> s >> t;
for (int i = 0; i < n; ++i) {
fin >> c[i] >> p;
c[i] -= i * s;
while (st <= dr && c[dq[dr]] >= c[i])
--dr;
if (st <= dr && dq[st] <= i - t)
++st;
dq[++dr] = i;
ans += 1LL * p * (c[dq[st]] + i * s);
}
fout << ans;
return 0;
}