Pagini recente » Cod sursa (job #1670363) | Cod sursa (job #2410886) | Cod sursa (job #634193) | Cod sursa (job #2698297) | Cod sursa (job #2731950)
#include <iostream>
#include<fstream>
#include<deque>
#include<vector>
#include <bits/stdc++.h>
using namespace std;
ifstream f("branza.in");
ofstream g("branza.out");
int N,S,T,suma=0,nr=0,i,x,y,b,ok=1,a;
//vector<int> C;
//vector<int> P;
int C[10000],P[10000];
deque<pair<int,int> > caut;
int main()
{
f>>N>>S>>T;
for(i=1; i<=N; i++)
{
f>>x>>y;
//C.push_back(x);
//P.push_back(y);
while(!caut.empty() && ( i-caut.front().second )>T)
caut.pop_front();
while(!caut.empty() && x<1LL*caut.back().first+1LL*S*(i-caut.back().second))
caut.pop_back();
caut.push_back({x,i});
suma+=1LL* y*(caut.front().first+1LL* S * ( i - caut.front().second ));
}
g<<suma;
}