Pagini recente » Cod sursa (job #1520224) | Cod sursa (job #1517137) | Cod sursa (job #1034418) | Cod sursa (job #509360) | Cod sursa (job #2731944)
#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,s=0,nr=0,i,x,y,b,ok=1,a;
//vector<int> C;
//vector<int> P;
int C[10000],P[10000];
deque<pair<long,long> > 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});
s+=1LL* y*(caut.front().first+1LL* S * ( i - caut.front().second ));
}
g<<s;
}