Cod sursa(job #3239807)
| Utilizator | Data | 7 august 2024 17:33:29 | |
|---|---|---|---|
| Problema | Branza | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.58 kb |
#include <fstream>
#include <deque>
#define cost first
#define timp second
using namespace std;
ifstream cin("branza.in");
ofstream cout("branza.out");
int n,s,t,p,c;
long long sol;
deque<pair<int,int>>q;
int main()
{
cin>>n>>s>>t;
for(int i=1;i<=n;i++){
cin>>p>>c;
while(!q.empty()&&i-q.front().timp>t)
q.pop_front();
while(!q.empty()&&q.back().cost+s*(i-q.back().timp)>=p)
q.pop_back();
q.push_back({p,i});
sol+=1LL*(q.front().cost+s*(i-q.front().timp))*c;
}
cout<<sol;
return 0;
}
